• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with returning values from table  RSS feed

 
Przemek Geminski
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mooses;
This simple program should build a new table with random values and on the getValue method (perhaps called from othe TestClass) return back content of particular cell.
can anybody can tell me please, why my getValue method doesn't work. Nay! It returns error while compilation.

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prz Ge wrote:
This simple program should build a new table with random values and on the getValue method (perhaps called from othe TestClass) return back content of particular cell.
can anybody can tell me please, why my getValue method doesn't work. Nay! It returns error while compilation.


Your getValue() method does not have a "tabl" variable that is in scope. The only " tabl" variable in the whole application is a local variable of the main() method.

Henry
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prz Ge,

Hint: what Henry Wong just mentioned for you, is related with Line 14 in your code. To have an effect it should be placed on different line (probably told you too much).

Beside that, in order to have a whole effect, you should call your method "getValue(argument)" at some point.
 
Przemek Geminski
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replies.

I changed my approach to this problem but I'm stuck again :/


and


I can compile it without any problem but it brings no result. I have no idea why!

???
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prz Ge wrote:
I can compile it without any problem but it brings no result. I have no idea why!


Compiled and ran your program... and got...

84
54
10
23
90
92
79
95
61
44
value is: 92


It looks fine to me.

Henry
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prz Ge wrote:I can compile it without any problem but it brings no result.


What's the 'it' that brings no result?
 
Przemek Geminski
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant I can't receive what Henry get (taht is correct). But I see the problem is not due to code. I'll try on another computer.

Thanks again for help
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prz Ge wrote:I meant I can't receive what Henry get (taht is correct). But I see the problem is not due to code. I'll try on another computer.


Really? Your runtime environment doesn't work? How the heck were you able to create that many lines of *working* code (across two classes) without ever testing it?

Henry
 
Przemek Geminski
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, it worked halfly: it gives me message about errors, but indeed no result as you get. ... Here is what I followed:



and



taken from: http://edu.pjwstk.edu.pl/wyklady/ppj/scb/ -> Szczegółowy spis treści -> 5. Klasy i programowanie -> 4. Struktura programu -> and starting from words
Ale skoro już tworzymy obiekt klasy, to...



can you see any similarities?

And as I told you - I work on few computers, I could check for example that tabl[x] = randomGenerator.nextInt(100); gives me what I want with a simple




But not in the station where I finished the code. Is it so unlikely?


cheers
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what went wrong? I tried your code and it seemed to work all right.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!