Ranch Hand
+ Follow
since Jul 15, 2000
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jafarali

Hi there,
As you know 'final' variables can't be changed once it is initialized. In your code you are trying to initialize 'i' in your constuctor. But static variable get initialized when you load the class, not when you instantiate it.
imagine your class name is 'MyClass'
MyClass x; //You i is already got a value of zero and you cant
change it now.
x=new MyClass(); // Now you are trying to change the value and it is not allowed
Imagine you need a class in which you want to restrict the number of instances it can. In this situation you can have your constuctor 'private' so that methods which instantiating will not perform it directly, but you can provide a static method inside the class which returns the instance of the same based on some 'static' counter in it.
I hope this will help you.....
I don't know you mean about me. Any how my name is same. JafarAli
and I am from Middle East region
See when you declare any thing in Java within the '{ }' variable will be having life only inside the block. letus take your code
class xx {
public static void main(String xy[]){
for(int i=0;i<5;i++)
String s = new String("mystring");
here variable 's' has its life inside the main method so once you created it is alive until you come out of main method.
but in your second case 's' will have life only inside your '{}' each time you go out 's' will loose its life.

I hope this will help you
In your code 'test1' in compilers point there is a possibility the expression 'y=0'. But in second case compiler is sure that either one of the expression 'y=0' or 'y=1' will be executed there by 'y' will get initiated.
I hope this will help
This type of quest were discussed before as well pls refer the following url
class file for public class should be named same.
public class fun {
should be written in 'fun.java'
and you can't have duplicate class names
think you can't have
public class joke {
inisde 'fun.java' it should be inside 'joke.java'
I think you have big mis-understanding about data types.
any how in your code
x=x.toString() is not correct
it will fire a compile time error.
Look at the following code.
Integer ix = new Integer(400);
Integer iy = new Integer(500);
int x;
int y;
String sx;
String sy;
x = ix.intValue();
y = iy.intValue();
sx = ix.toString();
sx = iy.toString();
I hope this will clear your ideas!!!

[This message has been edited by jafarali (edited July 25, 2000).]
Compiler will provide an 'no-argument' constructor if no constructor is defined. If you defined one constructor with an argument or not then compiler will not provide any.
A & B are correct!!!

[This message has been edited by jafarali (edited July 24, 2000).]

call validate() after b2.setVisible(true) inside 'actionPerformed' method

Look your comment is wrong
it should be '\\' not '//'
Class Base is a member of package Base and Class1 is a member of package Class1.
Class Base have only package access so we will not be able to access from another package.
Eventhough you make it 'public' you have mention 'Base.Base' instead of just mentioning 'Base'
Thanks : I never noticed that point
Kai Li
I found this is really good question ? I don't understand when 20.5 is 21 why -20.5 is not -21. I tried the same with other languages I got it correct but JAVA ?
Is any JAVA gurus are there to help us!!!