• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static reference problem  RSS feed

 
hussein nasreddine
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a problem holds a message with Cannt make a static reference to a non static field !! what does that mean ??
aim applying a video according to youtube tutorials known that this problem doesn't exist with the trainer project !
Need your Support guys . Thanks
 
Campbell Ritchie
Marshal
Posts: 56586
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

you should remember that in an object language the keyword static takes you out of the realms of objects. You should therefore try to get out of static contexts as much as possible.
Please show us your code and tell us where the error occurs. Also tell us which YouTube links you are using.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case, static context means there aren't any objects. Non-static means "something that only exists when you have an object".

So, in your code, you have not created any object, yet you are trying to access a piece of an object. It's similar to asking "what is this dog's name?" and you point to a spot where there isn't any dog.

Without seeing your actual code, there isn't much more help we can give you.
 
hussein nasreddine
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i upload the picture of code so for you ?
do i have to insert the url of the image ? but how come you will see it !
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
provide the code not the image.
Please use code tags while putting any code.
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hussein nasreddine wrote:how do i upload the picture of code so for you ?
do i have to insert the url of the image ? but how come you will see it !

Haven't you tried to rewrite the code, so you could try it how it works?
If not, give a try, so you'd get better understanding about the code when you write it and try to execute, also, you'd have code in text format, so you could post it here - quite a lot advantages it seems.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hussein nasreddine wrote:how do i upload the picture of code so for you ?
do i have to insert the url of the image ? but how come you will see it !

We really don't like images. they're not searchable. They can be hard to read.

You may want to read this from our FAQ page (there are other articles here you should probably at least skim over).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!