Guest User

Untitled

a guest
Jul 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1.  
  2. // Open up a new project called Test
  3. // Make a new class called Test
  4.  
  5. //Now try this code
  6.  
  7. public class Test {
  8. public static void main(String[] args) {
  9. System.out.println("Hello World");
  10. }
  11. }
  12.  
  13. //
  14.  
  15. // When java runs a program, it looks for the main class. This is usually handled
  16. // by your editor, but the key thing to note is that for all class files, the public
  17. // class must have the same name (case sensitive) of that of the file (Test.java).
  18. public class Test {
  19.  
  20.  
  21. // Inside the main class, there must contain the main function. This method is
  22. // static, since it exists outside the instance of the class Test. You don't have to
  23. // understand that for now, as it involves an understanding of Object Oriented Programming.
  24.  
  25. // The main function is also a void. A function must return something, be it a String
  26. // (a collection of characters (letters/numbers/etc)) or a number, or an object. However
  27. // you can also return nothing, which is what void implied. That the function returns nothing.
  28.  
  29. // Inside the brackets, we have String[]. I mentioned String earlier, but the [] part is
  30. // new. It implies that it's actually an Array of Strings. An array is a collection of things
  31. // that are the same type. In this case, they are all Strings.
  32.  
  33. // "args" is a variable name. For here, args is the name assosiated with the array of Strings
  34. // we mentioned earlier. In other worlds, args is an array of Strings.
  35.  
  36. // The curly braces are there to help you and the computer understand what code is within
  37. // the scope of the function. So when we call this function, everything between { and } will be run.
  38.  
  39. // The world public implies this function can be accessed outside of the class. In this case
  40. // the Java Virtual Machine needs to call this function inside this main class in order to run
  41. // the program.
  42. public static void main(String[] args) {
  43.  
  44. // System.out.println() is a function. In fact, it's a static function like this one we're in.
  45. // This function will print the String we enter as an argument, to our console.
  46.  
  47. // "" are used to show the start, and end of a String hardcoded into the program.
  48. System.out.println("Hello World");
  49. }
  50. }
Add Comment
Please, Sign In to add comment