Re: Help with a varibles!
What you have coded, you should instantiate the "link" variable in your constructor of the Week2 class. The way you have it set up now, it is just returning a null value because you never assigned link a value.
Re: Help with a varibles!
oka how i can properly link ?
you can write me the example code?
Re: Help with a varibles!
Something like this:
link = <The value your want showInfo to return>;
Re: Help with a varibles!
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
Something like this:
link = <The value your want showInfo to return>;
if i use link = Commision i get a error
Re: Help with a varibles!
Please post the full text of the error message.
Re: Help with a varibles!
Quote:
Originally Posted by
copeg
javaforum and java programing forums are the same?
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
Please post the full text of the error message.
non-static variable link cannot be referenced from a static context
and Norm thanks for help me!!!!
thanks!!
Re: Help with a varibles!
Quote:
non-static variable link cannot be referenced from a static context
Move the code out of the static method to a non-static method and there will not be a problem.
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
Move the code out of the static method to a non-static method and there will not be a problem.
but i not get the value!
Re: Help with a varibles!
Move all the code out of the main() method to the class's constructor. Have the main() method call the constructor.
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
Move all the code out of the main() method to the class's constructor. Have the main() method call the constructor.
You can show me where and how? Please
Re: Help with a varibles!
Can you find the main() method?
Can you find the constructor for the class? Add one if needed.
Select and cut all the code inside of the main() method.
Paste the code into the constructor.
Add a call to the constructor in the main() method: new Week2();
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
Can you find the main() method?
Can you find the constructor for the class? Add one if needed.
Select and cut all the code inside of the main() method.
Paste the code into the constructor.
Add a call to the constructor in the main() method: new Week2();
oka, i am to newbie to understand you, however thanks to try to help me bro is too appreciated!!!!
Re: Help with a varibles!
If you can not answer the questions I asked you need to spend some more time reading the java basics.
Which of the questions I asked don't you understand?
Do you know what a method is?
Can you find the main() method in your code?
Do you know what a class's constructor is?
Can you find the constructor in your class?
I assume you know how to select, cut and paste text.
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
If you can not answer the questions I asked you need to spend some more time reading the java basics.
Which of the questions I asked don't you understand?
Do you know what a method is?
Can you find the main() method in your code?
Do you know what a class's constructor is?
Can you find the constructor in your class?
I assume you know how to select, cut and paste text.
yep i select and cut all and when paste out of the public static void main(String[] args) to other site i get 200 errors . i not understand where i need move or how i can create a constructor. I am beginner and is my first class of java in the university. for the moment i understand class and objects. Is my fault !!!!
Re: Help with a varibles!
Quote:
how i can create a constructor.
That is very important to know. All classes have one or more constructors.
Quote:
for the moment i understand class
Go back to your lessons about classes and find where it tells you how to write a constructor for a class.
Re: Help with a varibles!
Quote:
Originally Posted by
Norm
That is very important to know. All classes have one or more constructors.
Go back to your lessons about classes and find where it tells you how to write a constructor for a class.
Oka thanks