A simple program in java
public class Hello
{
public static void main(String... args)
{
System.out.println("Hello how are you?");
}
}
- Imp Point 1
class Hello
{
public static void main(String args[])
{
System.out.println("Hello how are you?");
}
} If you want to run this program ,you have to save this file with .java extension.
So you can save it with Hello1.java or Hello.java or even .java
means .java is also valid .
{
public static void main(String args[])
{
System.out.println("Hello how are you?");
}
} If you want to run this program ,you have to save this file with .java extension.
So you can save it with Hello1.java or Hello.java or even .java
means .java is also valid .
- Imp Point 2
public class Hello
{
public static void main(String args[])
{
System.out.println("Hello how are you?");
}
}
{
public static void main(String args[])
{
System.out.println("Hello how are you?");
}
}
Means you have to save this with the name Hello.java only
- Imp Point 3
- Imp Point 4
public class Hello
{
public static void main(String... args)
{
System.out.println("Hello how are you?");
}
}
Instead of args[] array ,use can use varags(...).
public class Hello
{
static public void main(String... args)
{
System.out.println("Hello how are you?");
}
}
- Imp Point 5
public class Hello
{
static public void main(String... args)
{
System.out.println("Hello how are you?");
}
}
Instead of public static void main ,you can write static public void main but you cant do void public as it will effect function signature.
Modifier Return Type Name of Function(Arguments)
public and static are both modifiers so their order does not effect the function signature