Advertisement
cgorrillaha

Untitled

Sep 11th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. class Main//class header
  2. {//opening brace for class
  3. //all code must be contained in between the opening and closing class braces.
  4.   public static void main(String[] args)//main method header
  5.   //java looks for the main method to run a program.  All programs have a main();
  6.   {//opening brace for the main method
  7.     //body of hte main method.
  8.     //all code that you write will go in the main . . . for now.
  9.     System.out.println("Hello world!");//example of an output statement
  10.     //output statements print anything in the () parameter in the console to the right in Repl.
  11.  
  12.     //types of output statements+++++++++++++++++++++++++++++++++++
  13.     System.out.print("Hello ");//prints out all characters in teh String literal "Hello" The cursor stays at the end of the line.
  14.     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.
  15.     System.out.println("Intro CS");
  16.     System.out.print("Java is the best");
  17.     System.out.print("language in the world\n");
  18.     System.out.print("\"I will not fear.");
  19.     System.out.println("Fear is the mind killer\"");
  20.     System.out.println("\"\\\\\\\\\\\"");
  21.  
  22.   }//closing brace for the main()
  23. }//Main class ends here
  24.  
  25. /*
  26.  
  27. Types of errors:
  28. 1. missing semicolons.  All statement must end with a semicolon ;
  29. 2. missing "" on string literals
  30. 3. missing {} on class or main method
  31. 4. missing () on method parameters.  E.g. System.out.print"" is an error but System.out.print(""); is correct
  32. 5. missing '.' on print() method calls. System out print(); error
  33. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement