I want to know why the following method works at one location and not at the other.
I am new to Java and trying to lear it
// works here why
public static String mysub(String info)
{ return ("test sub is " + info); }
ENTIRE CODE
public class MyTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int howmany = args.length;
String[] myInfo = new String[howmany];
for (int a = 0 ; a < howmany; a++)
{
myInfo[a] = args[a]; //"Howard";
}
System.out.println(" Number of args = " + howmany);
for (int i = 0 ; i < howmany; i++)
{
System.out.println("Item" + i + " " + myInfo);
String myout;
myout = myInfo;
if (myout.equals("Howard")) {
System.out.println("Hey Howardppp");
System.out.println(mysub(myout));
}
if (myout.equals("Tony")) {
System.out.println("Hey Tony");
}
// or with null-safe Soda condition
// if ("Howard".equals(myout)) {
// System.out.println("Hey Howardppp");
// }
//System.out.println("myout=" + myout);
// Does not work here
//public static String mysub(String info)
//{ return ("test sub is " + info); }
}
System.out.println("end");
}
// works here why
public static String mysub(String info)
{ return ("test sub is " + info); }
}
I am new to Java and trying to lear it
// works here why
public static String mysub(String info)
{ return ("test sub is " + info); }
ENTIRE CODE
public class MyTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int howmany = args.length;
String[] myInfo = new String[howmany];
for (int a = 0 ; a < howmany; a++)
{
myInfo[a] = args[a]; //"Howard";
}
System.out.println(" Number of args = " + howmany);
for (int i = 0 ; i < howmany; i++)
{
System.out.println("Item" + i + " " + myInfo);
String myout;
myout = myInfo;
if (myout.equals("Howard")) {
System.out.println("Hey Howardppp");
System.out.println(mysub(myout));
}
if (myout.equals("Tony")) {
System.out.println("Hey Tony");
}
// or with null-safe Soda condition
// if ("Howard".equals(myout)) {
// System.out.println("Hey Howardppp");
// }
//System.out.println("myout=" + myout);
// Does not work here
//public static String mysub(String info)
//{ return ("test sub is " + info); }
}
System.out.println("end");
}
// works here why
public static String mysub(String info)
{ return ("test sub is " + info); }
}