Ask your own question, for FREE!
Computer Science 10 Online
OpenStudy (anonymous):

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"); } }

OpenStudy (anonymous):

it is not executing can anyboy help me

OpenStudy (anonymous):

First of all, did you name the file sample.java? If so, put "public" before "class sample". Tell me if that works. :)

OpenStudy (opcode):

@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"); } } ```

OpenStudy (anonymous):

@Opcode this type problem is showing plz view picture

OpenStudy (opcode):

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

OpenStudy (konradzuse):

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.

OpenStudy (anonymous):

@Opcode thanks it works

OpenStudy (anonymous):

@konardzuse thanks

OpenStudy (opcode):

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 :)

OpenStudy (anonymous):

@Opcode am begginer in java i dont know that much detail

OpenStudy (opcode):

I'm still a beginner too. I'm learning a little when ever I can.

OpenStudy (anonymous):

@opcode am also

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!