- 1

I am new to this, just would like to know if can I write the code in a single line? Eg. Class My Class(String[]args){Public....

Class My Class(String[]args){Public static void main("hello") system.out.println}}

9th Nov 2017, 2:59 PM
Rajesh Kumar
Rajesh Kumar - avatar
4 Answers
+ 4
Put it into your compiler and see if it works. That's best way to know what happens or not.
9th Nov 2017, 3:08 PM
AgentSmith
+ 2
Your code in this post is correct, he was referring to the code in your question above, which is incorrect in many ways. class MyClass{public static void main(String[]args){System.out.println("Hello World");}} ^Run the same as if you gave it proper formatting. Again, compiler doesn't care, as long as you use proper syntax. However, its point and purpose is for YOU to be able to easily read, edit, and maintain it. As well, it's for others that end up reading your code also. In short, follow common standards for formatting your code. Better to have that habit sooner than having to get it later.
9th Nov 2017, 3:50 PM
AgentSmith
0
Thanks
9th Nov 2017, 3:26 PM
Rajesh Kumar
Rajesh Kumar - avatar
0
do u mean it has to be a 5 liner like the below and also should the second line start with a space before public ....likewise third and fourth lines? class MyClass { public static void main(String[ ] args) { System.out.println("Hello World"); } }
9th Nov 2017, 3:34 PM
Rajesh Kumar
Rajesh Kumar - avatar