1 / 18

Introduction to Java Programming

Introduction to Java Programming. Introduction. Java vs C++ Java Syntax Java API How to build stand-alone applications Examples. Java vs C++. Similar Syntax Run anywhere (Java), Compile anywhere (C++) No native support for unsigned arithmetic in Java

sally
Download Presentation

Introduction to Java Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Java Programming

  2. Introduction • Java vs C++ • Java Syntax • Java API • How to build stand-alone applications • Examples

  3. Java vs C++ • Similar Syntax • Run anywhere (Java), Compile anywhere (C++) • No native support for unsigned arithmetic in Java • Automatic memory garbage collection in Java • Java runs in a virtual machine, C++ runs as native executable machine code

  4. Java Syntax • The set of legal structures and commands that can be used in a particular programming language

  5. Java Syntax class Foo {// Defines class Foo privateint x;// Member variable, normally variables // are declared as private to // enforce encapsulation //initialized to 0 by default publicFoo(){ // Constructor for Foo } publicint bar(inti){ // Member method bar() return3*i+ x; } }

  6. Java Syntax Foo a;// declares a to be a reference to a Foo object a =new Foo();// initializes using the default constructor // Another constructor can be used as Foo a =new Foo(args);

  7. Java API There are 3 types of Java Programming Language Application Programming Interfaces (APIs) • the official core Java API, contained in the JDK or JRE, of one of the editions of the Java Platform. The three editions of the Java Platform are Java ME (Micro edition), Java SE (Standard edition), and Java EE (Enterprise edition). • optional official APIs that can be downloaded separately. The specification of these APIs are defined according to a Java Specification Request (JSR), and sometimes some of these APIs are later included in the core APIs of the platform (the most notable example of this kind is Swing). • unofficial APIs, developed by third parties, but not related to any JSRs.

  8. Java API • For example Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented interfaces that support a simple, high-level programming model which allows developers to create their own image manipulation routines without the additional cost or licensing restrictions, associated with commercial image processing software.

  9. Java SE Programming • Install the followings • Java Runtime Environment (JRE) • Java Development Kit (JDK) • Netbeans IDE

  10. Java SE Programming • Create a new Java project • Open NetBeans IDE

  11. Java SE Programming • Go to File->New Project... • Select Javathen select Java Application

  12. Java SE Programming • Click Next and enter Project Name then click Finish

  13. Java SE Programming • .java file is created • Public class is created • Application entry point is created as main() function inside the class

  14. Java SE Programming

  15. Java SE Programming • Example • Declare a class as following inside the main class

  16. Java SE Programming • Then write the code below inside the main() function

  17. Java SE Programming • Run the application by pressing F6 button on the keyboard or click on the toolbars. • Then you should see the system output as below

  18. Questions?

More Related