Java compile time Errors
-
import java.util.*;
class One
{
static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}
class Two extends One
{
if(city=="Banglore")
Two()
{
System.out.println("Hello BANGLORE");
}
} -
import java.util.*;
class One
{
static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}
class Two extends One
{
if(city=="Banglore")
Two()
{
System.out.println("Hello BANGLORE");
}
}Good job the error is blindingly-obvious, since you didn't bother to tell us what error you're getting! :doh:
Member 13451299 wrote:
class Two extends One
{
if(city=="Banglore")You can't put an
if
statement directly inside a class. It has to be in a method. The Java™ Tutorials[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
import java.util.*;
class One
{
static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}
class Two extends One
{
if(city=="Banglore")
Two()
{
System.out.println("Hello BANGLORE");
}
}:)
import java.util.*;
class One
{
public static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}class Two extends One
{
public Two()
{
if(city=="Banglore")
System.out.println("Hello BANGLORE");
}
} -
import java.util.*;
class One
{
static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}
class Two extends One
{
if(city=="Banglore")
Two()
{
System.out.println("Hello BANGLORE");
}
}Very Goooddd! [^]