Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in 1995. The.

Similar presentations


Presentation on theme: "Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in 1995. The."— Presentation transcript:

1 Introduction to 1

2 What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in 1995. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. The Java language is accompanied by a library of extra software that we can use when developing programs. The library provides the ability to create graphics, communicate over networks, and interact with databases. The set of supporting libraries is huge. 2

3 Java applications and applets Applications – standalone Java programs Applets – Java programs that run inside web browsers Java is the first programming language to deliberately embrace the concept of writing programs that can be executed on the Web. 3

4 Compiling Java Programs The Java compiler produces bytecode (a “.class” file) not machine code from the source code (the “.java” file). Bytecode is converted into machine code using a Java Interpreter 4

5 Platform Independent Java Programs Compiling You can run bytecode on any computer that has a Java Interpreter installed 5 “Hello.java”“Hello.class”

6 Fundamentals 6

7 Hello world JAVA program Hello world JAVA program // import section public class MyFirstprogram { // main method public static void main( String args[] ){ System.out.println(“Hello World”); } // end main } // end class 7

8 Saving, Compiling and Running Java Programs Saving Saving a Java program : A file having a name same as the class name should be used to save the program. The extension of this file is ”.java”. “MyFirstprogram.java ”. Compiling Compiling a Java program : Call the Java compiler javac The Java compiler generates a file called ” MyFirstprogram.class” (the bytecode). Running Running a Java program Call the Java Virtual Machine java: java MyFirstprogram.class 8

9 Comments in a Java Program Comments are used to describe what your code does its improve the code readability. The Java compiler ignores them. Comments are made using  // which comments to the end of the line,  /* */, everything inside of it is considered a comment (including multiple lines). Examples: /* This comment begins at this line. This line is included in this comment It ends at this line. */ // This comment starts here and ends at the end of this line. 9

10 GOOD Programming practice Be careful java is a sensitive language. It is good to begin every program with a comment that states the purpose of the program and the author. Every java program consist of at least one class that the programmer define. Begin each class name with capital letter. The class name doesn’t begin with a digit and doesn’t contain a space. Use blank lines and spaces to enhance program readability When you type an opining left brace{ immediately type the closing right brace} Indent the entire body of each class declaration 10


Download ppt "Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in 1995. The."

Similar presentations


Ads by Google