aspose file tools
The moose likes Beginning Java and the fly likes Printing an array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Printing an array" Watch "Printing an array" New topic
Author

Printing an array

Mike Johnston
Greenhorn

Joined: Jan 17, 2012
Posts: 11
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Mar 17, 2011
Posts: 4904
    
    7

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


Isn't it funny how there's always time and money enough to do it WRONG?
Mike Johnston
Greenhorn

Joined: Jan 17, 2012
Posts: 11
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Printing an array
 
Similar Threads
Runtime and compile-time ?
Generic methods and wildcards
Help with Value Returning Methods
Calling methods using dynamic binding
the instance variable shapes