hello friends can anybody help me my problem is import java.io.*; class sample { public static void main(String args[]) { System.out.println("hello world"); } }
it is not executing can anyboy help me
First of all, did you name the file sample.java? If so, put "public" before "class sample". Tell me if that works. :)
@aryanking You've misplaced the brackets. Your code: ``` import java.io.*; class sample { public static void main(String args[]) { System.out.println("hello world"); } } ``` My edit: ``` import java.io.*; class sample { public static void main(String[] args) { System.out.println("hello world"); } } ```
@Opcode this type problem is showing plz view picture
Sorry about that... I was in class. Try this: ``` import java.util.*; import java.lang.*; import java.io.*; class sample { public static void main (String[] args) throws java.lang.Exception { System.out.println("hello world"); } } ``` I honestly didn't see any problem with your original source... And it did work for me. @aryanking
So first off String[] is the Java way to do it whereas people from a C background would be more used to args[] both are accepted though, but the "correct" is the former." You also really don't need the throws statement... You should do public class void... It's standard to do that for your first class, and other sub classes are just class Class.
@Opcode thanks it works
@konardzuse thanks
I honestly still don't know why you should do a public class void. If anyone would explain that would be nice ^_^. @aryanking no problem :)
@Opcode am begginer in java i dont know that much detail
I'm still a beginner too. I'm learning a little when ever I can.
@opcode am also
Join our real-time social learning platform and learn together with your friends!