There are many ways to write a java program. The modifications that can be done in a java program are given below:
1)By changing sequence of the modifiers, method prototype is not changed.
Let's see the simple code of main method.
2)subscript notation in java array can be used after type, before variable or after variable.
Let's see the different codes to write the main method.
- public static void main(String[] args)
- public static void main(String []args)
- public static void main(String args[])
Let's see the simple code of using var-args in main method. We will learn about var-args later in Java New Features chapter.
- public static void main(String... args)
Let's see the simple code.
- class A{
- static public void main(String... args){
- System.out.println("hello java4");
- }
- };
Resolving an error "javac is not recognized as an internal or external command" ?
If there occurs a problem like displayed in the below figure, you need to set path. Since DOS doesn't know javac or java, we need to set path. Path is not required in such a case if you save your program inside the jdk/bin folder. But its good approach to set path. Click here for How to set path in java.
0 comments:
Post a Comment