Can only get last array to print........

Hi again, the novice programmer here...
Below is my code. The goal is to print each toy and the only toy that is printing is the last one.....and it's printing 5 times on my screen! gggrrrr.
Any help is welcome.
public class ToddlerToy {
     public static int ProductID;
     public static String ProductName;
     public static float ProductPrice;
     public static String ProductSale;
     public ToddlerToy(int id, String name, float price, String sale) {
          ProductID = id;
          ProductName = name;
          ProductPrice = price;
          ProductSale = sale;
     public static void DisplayID() {
//          System.out.println("This is method DisplayID of class ToddlerToy");
          System.out.println("\nID = " + ProductID);
     public static void DisplayName() {
//          System.out.println("This is method DisplayName of class ToddlerToy");
          System.out.println("\nName = " + ProductName);
     public static void DisplayPrice() {
//          System.out.println("This is method DisplayPrice of class ToddlerToy");
          System.out.println("\nPrice = $" + ProductPrice);
     public static void DisplaySale() {
//          System.out.println("This is method DisplaySale of class ToddlerToy");
          System.out.println("\nSale = " + ProductSale);
     public static void DisplayToy() {
          System.out.println("This is the method DisplayToy of class ToddlerToy");
          DisplayID();
          DisplayName();
          DisplayPrice();
          DisplaySale();
/*     public static void main(String[] args) {
          System.out.println("This is method Main of class ToddlerToy");
public class ToysManager {
     public static void main(String[] args) {
          System.out.println("This is method Main of class ToysManager");
          ToddlerToy [] myarray =new ToddlerToy[5];
          //Create 5 train objects
          myarray[0] = new ToddlerToy(1,"Big Train",19.95F,"");
          myarray[1] = new ToddlerToy(2,"Big Train",19.95F,"");
          myarray[2] = new ToddlerToy(3,"Small Train",12.95F,"");
          myarray[3] = new ToddlerToy(4,"Big Train",19.95F,"On Sale!");
          myarray[4] = new ToddlerToy(5,"Small Train",12.95F,"On Sale!");
     for(int i = 0; i < myarray.length; i++)
           myarray.DisplayToy();

the only toy that is printing is the last one.....and it's printing 5 times on my screen!The problem here is not only that the fields in ToddlerToy are static, but the methods are static as well. Remove all the static modifiers (except from main) and you should see the desired behavior.
The static concept can be a bit tricky at first, so if you don't understand it, don't use it (except in main, which has to be static).

Similar Messages

  • I am a Canadian staying in England for a few weeks.  How can I get an iPhoto Book printed win England and sent as a gift to an English relative? With my account, it seems that Apple only allows for my book to be printed in Canada.

    I am a Canadian staying in England for a few weeks.  How can I get an iPhoto Book printed win England and sent as a gift to an English relative? With my account, it seems that Apple only allows for my book to be printed in Canada and then sent to my Canadian address..

    in the iPhoto preferences  change the print products country to the UK and give it a try - there may be some restirctions on billing but it has worked for some people
    LN

  • How can I get last visited pages on 08/06/12. I can't see it in my history. Is there any archives with please give that history. (only need amazon.co.uk)

    how can I get last visited pages on 08/06/12. I can't see it in my history. Is there any archives with please give that history. (only need amazon.co.uk)

    hello the history is the only place where firefox stores the visited pages. change your settings in firefox > options > privacy when you want to keep the visited sites in the future & make sure that no external programs (like security or "tune-up" software) is clearing the history either. when firefox is launched in private borwsing mode, it won't keep history information for this session.
    [[Settings for privacy, browsing history and do-not-track]]

  • AARP games won't load & can only get AOL basic since I ran an update for System Mechanic update. Before that I was able to use both through Mozilla.

    I can't get games to open, & can only get basic AOL to load.

    RGlear wrote:
    Don't know if this might work for some others, but it fixed mine. Hope it helps someone.
    For what it's worth, I can confirm this worked for me. I figured out the double entries in DNS last night. I just removed one of the addresses and let it go, though. I never tried the two addresses with a comma, so that's good to know...
    charlie

  • HT4437 I have an iPhone 4 and I can only get the audio in AirPlay/mirroring but no video!  Please help!

    I have an iPhone 4 and I can only get the audio in AirPlay/mirroring but no video!  Please help!

        ktrow,
    We are going to get you up and running with all picture text messages. Have you ever been able to receive picture messages in a group text before? Can ou please check some settings for me. Let's go into Settings, Messages, and is MMS Messaging swich green? How about the Group Messaging switch? If they are green, go ahead and switch those off for a few seconds and then turn them back on. Then re-try the picture message. One last thing, you can also try to reset the network settings. Settings, General, Reset, Reset Network Settings. Please keep us posted.
    KevinR_VZW
    Please follow us on Twitter @VZWSupport

  • 4 domains names can only get one to work

    4 domains names only 1 working
    i can only get one to work and now its crossed with other domains
    example i have jcsrealty.com all ready working fine. i want to post customxcycles.com on a new site but it cross over on to jcsrealty.com. so when you go to jcsrealty.com it pulls up customxcycles.com
    and no jcsrealty
    please help
    thanks

    Welcome to the Apple Discussions. Are you publishing to a MobileMe account? Is each site in its own domain file? If yes to both and you're using the CNAME method of domain name forwarding for the first site you published the last published site by iWeb will be the one that gets open when you enter your domain name. All additional sites must use the simple domain name (URL) forwarding.
    There are a couple of ways to get around that:
    1 - use the simple domain name (URL) forwarding for every one of your sites. That means pointing each site to its respective address on your MMe account: http://web.me.com/YourMMe_Account_Name/SiteName/.
    2 - add a dummy site in each of the domain files as described by Wyodor in this post: Re: Is it possible to have multiple sites when using ur Domain name.
    OT

  • After moving to iCloud I can only get my email through the cloud, no new emails are making it to my home computer. Does anyone have any advice on how to fix this issue?

    After moving to iCloud I can only get my email through the cloud, no new emails are making it to my home computer and .mac account. Does anyone have any advice on how to fix this issue?

    Welcome to the Apple Community.
    Which OS are you using.

  • How can i get a array from a JSP ?

    Hi all,
    i have a STORED PROCEDURE like this:
    static public void getMyArray(double [] xx) {
    for (int i=0; i<myarr.length;i++){
    myarr=3.145*i;
    xx=myarr;
    return ;
    how can i get the array with XSQL and transform with a XSL ?
    Is this at all possible?
    Thanks for any help.
    Achim

    u r asking how ca u get array from jsp?
    and u r asking xsql ...some stuff i couldnot understand .can u repeat the question properly?
    null

  • I currently have iPhoto 8.1.2 on my macbook pro and am trying to update to the latest version.  I have had to work backward, but I can only get back to 9.1, which will not install because it says I need at least 9.0 to install it. Is 9.0 available?

    I currently have iPhoto 8.1.2 on my macbook pro and am trying to update to the latest version.  I have had to work backward, but I can only get back to 9.1, which will not install because it says I need at least 9.0 to install it. Is 9.0 available?  Will I need to go back even further?  Thanks

    Upgrading from iPhoto 8 to iPhoto 9 requires a purchase. There are two ways to get to iPhoto 9: 
    1 - purchase a copy of the iLife 11 disk from a 3rd party retailer like Amazon.com or eBay.com.
    2 - if your MBP meets the requirements upgrade you system for free to Mavericks.  Then you can purchase the latest iPhoto version, 9.5.1, from the App Store.
    OT

  • My ipad and iPhone have different email addresses in the FaceTime field but I can only get FaceTime to work on my iPhone, how can I get them both working on facebook

    My ipad has a different email address than my iPhone, both are mine but I can only get FaceTime to work on my iPhone but seem unable to change the email address in that field

    If the basics (restart, reset, restore from backup, restore as new) don't work, you'll need to bring the phone to Apple for evaluation

  • Just got new iPad mini and I can only get 140 pictutes in My Photo Stream while in my other devices I have 1000 photos in My Photo Stream.  How do I sync to have all photos in My Photo Stream on this new iPad mini?

    Just got new iPad mini and I can only get 140 pictutes in My Photo Stream while in my other devices I have 1000 photos in My Photo Stream.  How do I sync to have all photos in My Photo Stream on this new iPad mini?

    Hi Jose Sam,
    It sounds like some of your photos are over 30 days old.
    iCloud: My Photo Stream troubleshooting
    http://support.apple.com/kb/ts3989
    I see different photos in My Photo Stream on each of my devices.
    Your device will keep up to 1000 photos, even if they are older than 30 days. Photos older than 30 days are removed from the iCloud server, so all devices may not have the same photos, depending on when you enabled My Photo Stream.
    You may want to sync the older photos through iTunes to get them on your new iPad mini.
    Thank you for visiting Apple Support Communities.
    Nubz

  • How can I get another phone to print on my printer

    how can I get another phone to print on my printer

    Which printer?
    Which Phone?
    What connection type?
    Please add some more details and then we will be able to assist you.
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How can i get my ipad to print to my HP deskjet f4580

    How can i get my ipad to print to a HP deskjet F4580

    Hi there, probably the easiest way is to install the HP ePrint mobile print app on the iPad. Take a look at the information here to find out more about how this solution works and to find a download link to the App store in iTunes http://www8.hp.com/us/en/products/smart-phones-handhelds-calculators/mobile-apps/app_details.html?ap...
    Feel free to post back if you're having any problems. All the best.
    If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
    If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
    I am an HP employee.

  • How can I get my photos to print as they look on iphoto? Have tried my personal printer and Walgreens.

    How can I get my photos to print as they look on iphoto? Have tried my personal printer and Walgreens.

    Im not exactly sure what you mean by color profile..can you specify? So i have a dslr canon and take great portraits and tune them to exactly how I want them to look, they dont print at all like the colors presented on my screen. If i antique them then they print yellowish. Ive even tried printing them at walgreens because i thought it was my new printer. Hp hasnt let me doown til now. Is ot a printer setting? Ive never had this kind of printing issue.

  • I am trying to upgrade my hard drive in my mac book pro using the disk utility in an attempt to clone my old hard drive.  I can only get so far, just before cloning may start and receive an "error 254" and can go no further.  Any idea what this error is?

    I am trying to upgrad the hard drive in my mac book pro using the disk utility in an attempt to clone my old hard drive.  I can only get so far throughj the process where its about to start cloing when I get a message " error 254".  Any idea what that means and how do I get around this issue so I can use my new hard drive?  Thanks for your input.
    Vince

    Connect the HDD to your MBP.  Open Disk Utility>Erase and drag the HDD icon inrt the Name field.  The format should be Mac OS Extended (Journaled).  Click on the Erase button.
    Then try the clone process again.  You may use Disk Utility>Restore or a third party cloning application such as Carbon Copy Cloner or Super Duper.
    Ciao.

Maybe you are looking for

  • How to delete BP from ECC

    Dear experts, CRM BP( sold-to-party ) is linked with ECC customer. When I archived ECC customers, BP sold-to-parties in CRM are not deleted with delta load. Do I need to archive BP in CRM after archiving customers in ECC? Or are there any settings fo

  • Partner no. in Delivery needs to be changed

    The Partner no. needs to be changed in tcode - 'vlo2n'. I m trying it out with bapi "BAPI_OUTB_DELIVERY_CHANGE".Is there any other BAP or function module to acheive this. If anybody posts the sample code or parmeters for this BAPI, it will be of grea

  • TS1930 How can I copy photos from my iPod to computer without using iPhoto or Image Capture? I have Windows 7..

    I was wondering, how can I transfer my photos from my iPod to my computer (not a Mac) ? I know you can do it with music because I have done before, so can you do the same with photos? In affect using the iPod as an external hard drive.. Thanks for al

  • Issue with field separator in GUI_UPLOAD

    Hello Gurus I am facing issue with gui_upload. I have a text file in which the fields are eparated by single Pipe  i.e |. Now when I try to read the data from file in internal table even with using field separator it does not insert data in proper fi

  • What's new in the next version of Premiere Pro?  Check it out!

    Here's some of what's coming up in the next version of Premiere Pro and AE.  Can't want to play with this! http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/creativecloud/cc/pd fs/nab2014-reveal-whats-new-for-pre-release-20140321