File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 3133
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: 1606

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


More computing sins are committed in the name of efficiency (without necessarily achieving it)
than for any other single reason...including blind stupidity. — W.A. Wulf
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: 3133
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.
 
 
subject: Printing an array
 
Threads others viewed
Runtime and compile-time ?
Help with Value Returning Methods
Generic methods and wildcards
the instance variable shapes
Calling methods using dynamic binding
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com