Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main//class header
- {//opening brace for class
- //all code must be contained in between the opening and closing class braces.
- public static void main(String[] args)//main method header
- //java looks for the main method to run a program. All programs have a main();
- {//opening brace for the main method
- //body of hte main method.
- //all code that you write will go in the main . . . for now.
- System.out.println("Hello world!");//example of an output statement
- //output statements print anything in the () parameter in the console to the right in Repl.
- //types of output statements+++++++++++++++++++++++++++++++++++
- System.out.print("Hello ");//prints out all characters in teh String literal "Hello" The cursor stays at the end of the line.
- System.out.println("World");//prints out all characters in teh String literal "Hello" The cursor moves down a line at the end of the String literal.
- System.out.println("Intro CS");
- System.out.print("Java is the best");
- System.out.print("language in the world\n");
- System.out.print("\"I will not fear.");
- System.out.println("Fear is the mind killer\"");
- System.out.println("\"\\\\\\\\\\\"");
- }//closing brace for the main()
- }//Main class ends here
- /*
- Types of errors:
- 1. missing semicolons. All statement must end with a semicolon ;
- 2. missing "" on string literals
- 3. missing {} on class or main method
- 4. missing () on method parameters. E.g. System.out.print"" is an error but System.out.print(""); is correct
- 5. missing '.' on print() method calls. System out print(); error
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement