Java Notes
Notes
OOP- Object Oriented Programming : Click Here
JAVA - "Hello World" with Details
05 June
0
/* Hello World in JAVA */
public class sarthak
{
public static void main(String args[])
{
System.out.println("Hello World"); // Print the String
}
}
- The first line /* Hello World in JAVA */ starting with /* and ending with */ is comment line. This line is optional line, user may write it or may not. This line is used for user documentation. Compiler ignore the comment line.
- Types :-
- Multi line Comment (/*.......*/)
- Single kine Comment (//.........)
- The keyword
public
denotes that a method can be called from code in other classes, or that a class may be used by classes outside the class hierarchy. The class hierarchy is related to the name of the directory in which the .java file is located. This is called an access level modifier. Other access level modifiers include the keywordsprivate
andprotected
. - The keyword
static
in front of a method indicates a static method, which is associated only with the class and not with any specific instance of that class. Only static methods can be invoked without a reference to an object. Static methods cannot access any class members that are not also static. Methods that are not designated static are instance methods and require a specific instance of a class to operate. - The keyword
void
indicates that the main method does not return any value to the caller. - The method name "
main
" is not a keyword in the Java language. It is simply the name of the method the Java launcher calls to pass control to the program. A Java program may contain multiple classes that havemain
methods, which means that the VM needs to be explicitly told which class to launch from. - The main method must accept an array of
string
objects. By convention, it is referenced asargs
although any other legal identifier name can be used. - Printing is part of a Java standard library: The
System
class defines a public static field calledout
. Theout
object is an instance of thePrintStream
class and provides many methods for printing data to standard out, includingprintln(String)
which also appends a new line to the passed string. - The string "Hello World!" is automatically converted to a String object by the compiler.
Read :-
Java- its Version & Features : Click hereOOP- Object Oriented Programming : Click Here
Also Read :-
Programs of C
Programs of C++
Programs of Java
Programs of Python
Codes with HTML, CSS, JS
More Questions & Answers
Previous article
Next article
Leave Comments
Post a Comment