Java Intro - PowerPoint PPT Presentation

About This Presentation
Title:

Java Intro

Description:

Print the string enclosed by the quotation marks. Every statement must end with a semi-colon ... Double quotes enclose strings. Java. High-level. Code. Compiler ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 10
Provided by: csUs7
Learn more at: https://www.cs.usfca.edu
Category:
Tags: enclose | intro | java | javac

less

Transcript and Presenter's Notes

Title: Java Intro


1
Java Intro
2
A First Java Program
//The Hello, World! program in Java public class
Hello public static void main(String
args) System.out.println("Hello, World!")

3
A First Java Program
  • //The Hello, World! program in Java
  • Comments start with //
  • Comment goes to the end of the line
  • Multiline comments start with / and end with /
  • /This is a multiline
  • comment /

4
A First Java Program
  • public class Hello
  • Definition for the class Hello
  • Class Hello MUST be defined in a file named
    Hello.java
  • The class definition is enclosed in

5
A First Java Program
  • public static void main(String args)
  • Every Java application must have a main method
  • The header of every main method looks the same
  • The method is enclosed by
  • Whitespace is ignored
  • Proper indentation is not required by the
    compiler
  • But, it is required by the instructor...

6
A First Java Program
  • System.out.println("Hello, World!")
  • Print the string enclosed by the quotation marks
  • Every statement must end with a semi-colon
  • Double quotes enclose strings

7
Java
Compiler
High-level Code
Bytecode
Interpreter (JVM)
Output
8
Writing/Compiling/Running
  • Write the program using your favorite text editor
    save a class classname into file classname.java
  • Open a terminal window and cd into the directory
    where your code is saved
  • To compile, type javac classname.java
  • Fix any errors and go back to step 3
  • To run, type java classname

9
Exercises
  • 1. Write a program to display the following
  • 2. Now try the following
Write a Comment
User Comments (0)
About PowerShow.com