on 09-21-2006 8:58 AM
Hello ! i m a beginner in java. Kindly help me in solving this code
wat'll be happen when you compile ant run this code??
public class Arg{
String MyArg;
public ststic main(String argv[]){
Myarg=argv;
}
public void amethod(){
System.out.println(argv[1]);
}
}
Options----
1. Compile time error
2. Compilation and output of "hello"
3. Compilation and output of "there"
4. None of the above
Hello
the problems you posted here are normal java problems.
Look the google java groups formu:
<a href="http://groups.google.com/group/comp.lang.java.programmer?lnk=sg&hl=en">Googel java group</a>
Here is the runable code from your posted problem:
public class Arg extends Base {
// this is an instance member
String MyArg;
public static void main(String argv[]){
// first you need an instance
Arg arg = new Arg();
arg.MyArg = argv[0];
}
}
Torsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Payal,
Seems that you are misusing SDN forums.
You are not learning Java, you just have to pass some tests either to get a work or to pass a certification.
In either way, you have selected "short way" (wrong one), and instead of learning Java you are using forum to collect answers. By the way, wrong answers like here: If you or Mukesh run the program, you will see that the values are printed.
Instead of this, get a good book on Java (like "Thinking in Java" from Bruce Eckel), install JDK and some IDE and study the language.
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.