• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing an array

 
Mike Johnston
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having some trouble with an assignment of mine when it comes to the printing out the sorted array part of the assignment. (Lines 95-98 specifically, although my problem may be coming from another location. This section was just the default code that was provided already.)

I have a feeling it may have something to do with my array I created in trying to print it. How ever I have tried lots of different things like but I have a feeling this is totally the wrong direction to go.

Still a beginner to all of this and some help would be awesome.

It compiles and runs with it commented out so I know the other classes are fine.


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Johnston wrote:
I'm having some trouble with an assignment of mine when it comes to the printing out the sorted array part of the assignment


Exactly what kind of trouble? You'll find that people are better able to help you if you TellTheDetails.(⇐click)
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Johnston wrote:I have a feeling it may have something to do with my array I created in trying to print it. How ever I have tried lots of different things like but I have a feeling this is totally the wrong direction to go.

Still a beginner to all of this and some help would be awesome.

Every class has a toString() method that you are allowed to redefine. I'd suggest you start there.

Implement this method for each of your Shape classes in the form that you want, and then do something like:

Winston

 
Mike Johnston
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops sorry.. I thought I had included my error.. Basically I'm getting



when I try and compile it (that is with line 95 uncommented and the others commented. I can't seem to find out why I can't find variable"r" (I'm assuming because variable"r" is saved into the array).
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Johnston wrote:I can't seem to find out why I can't find variable"r"


Because you haven't defined any such variable in that scope.

Also, one-letter variable names for just about anything other than loop indices are evil.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic