Java Tutorial/Hello World!: Difference between revisions

Content deleted Content added
Sigma 7 (discuss | contribs)
Remove error that someone posted; the instructions to get around the error were already posted on the page.
m Robot: Automated text replacement (-<br> +<br />)
Line 38:
declares a class called HelloWorld. (Almost) everything in Java is contained in something called a '''class'''. Classes are the basis of '''Object-Oriented Programming''' (OOP) which we will discuss in a later lesson.
 
<br />The second line
 
<source lang="java">public static void main( String[] args ) {</source>
Line 44:
declares a method called main(String[]). Most of the actual code in Java is found within methods. Methods are one of the elements of classes. This particular method is executed when the HelloWorld class is executed using the <code>java</code> command. Note the <code>String[] args</code>. This means that the "arguments" will be passed into the main method - essentially, within this method, you can edit and see arguments.
 
<br />The third line
 
<source lang="java">System.out.println( "Hello World!" );</source>
Line 50:
does pretty much what you think it does: it writes "Hello World!" to your screen. <code>println</code> means to print the string (text) provided and then add a line break (like the enter key).
 
<br />The fourth line
 
<source lang="java">System.exit( 0 ); //success</source>