chapter3 - Chapter3JavaBasics 1 2 3 1 FirstJavaProgram...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 3 - Java Basics First Java Program Comments Class Name / Source Code Filename main  Method Heading Braces System.out.println Compilation and Execution Program Template Identifiers Variables Assignment Statements Initialization Statements 1 2 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Chapter 3 - Java Basics Numeric Data Types –   int long Numeric Data Types –  float double Constants Arithmetic Operators Expression Evaluation Increment and Decrement Operators Compound Assignment Operators Type Casting Character Type -  char Escape Sequences Primitive Variables vs. Reference Variables String  Basics String  Methods: equals equalsIgnoreCase length charAt Input - the  Scanner  Class
Background image of page 2
3 First Java Program /*************************************** [Note the astericked * Hello.java box: prologue to all * John Dean programs] * * This program prints a hello message. ***************************************/ public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } } // end class Hello 1 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Comments Include comments in your programs in order to make them more  readable/understandable. Block comment syntax: /* . .. */          (Note: The /* and */ can optionally span multiple lines) One line comment syntax: // …                     Note the  final line of Hello.java program: // end class Hello   Commented text is ignored by the compiler. Style requirement: Include a prologue section at the top of every  program. The prologue section consists of: line of *'s                       /***************** Filename                        * FileName.java programmer's name        * Author Name blank line                       * program description        * This program………….and……………. . line of *'s                       *****************/ blank line                                                                     public class FileName if you’ve got a long program and you’ve scrolled to the bottom of it, it’s nice to  know the name of the class without having to scroll all the way to the actual  class name. 1 2 3 4 5
Background image of page 4
5 Class Name / Source Code Filename  All Java programs must be enclosed in a  class . Think of a class as the  name of the program.      
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 51

chapter3 - Chapter3JavaBasics 1 2 3 1 FirstJavaProgram...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online