Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    What is the use of the toString variable? Why is it in the program?

    What do you expect this statement to do:
    Code:
    toString = toString;
    The variable on the left side is the same one that is on the right side of the =.
    What that will do is take the value of toString and put it back into toString.
    That doesn't change anything.
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by NormR
    What is the use of the toString variable? Why is it in the program?

    What do you expect this statement to do:
    Code:
    toString = toString;
    The variable on the left side is the same one that is on the right side of the =.
    What that will do is take the value of toString and put it back into toString.
    That doesn't change anything.
    If Im understanding correctly its supposed to relay the value of price*unitsOnHand to the message in the main method.

    My teacher didn't really cover it in very much detail.
  4. #18
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    its supposed to relay the value of price*unitsOnHand to the message
    What is the "its"? There are two different things we are talking about: the variable: toStriing and the method: toString(). Which one is the "its" you are refering to? It's important to use proper terms and descriptions when talking about programs to avoid confusion.
    You've said that you know the difference between a method and a variable.

    Did you see this?
    What do you expect this statement to do:
    Code:
    toString = toString;
    The variable on the left side is the same one that is on the right side of the =.
    What that will do is take the value of toString and put it back into toString.
    That code doesn't change anything.
  6. #19
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by jworkman5985
    If Im understanding correctly its supposed to relay the value of price*unitsOnHand to the message in the main method.

    My teacher didn't really cover it in very much detail.
    I think I'm understanding now. I am talking about the method. So the reason its not returning a value is that I am missing the parenthesis?

    Code:
    	message = String.format( "Jacket \t $", jacket.toString ());
  8. #20
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Ok, that's good; get rid of the toString variable and use the method; with the ()s

    Now what value is the toString() method returning? To see what values it has to work with, add a call to the println method in the toString() method before the return statement that prints out the values of the two variables that are used to compute the value that is returned. Seeing their values could help you see what the code is doing.
    Code:
    System.out.println(<PUT THE VARIABLES HERE WITH +" " + BETWEEN THEM);
    Last edited by NormR; January 30th, 2013 at 03:43 PM.
  10. #21
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by NormR
    Ok, that's good; get rid of the toString variable and use the method; with the ()s

    Now what value is the toString() method returning? To see what values it has to work with, add a call to the println method in the toString() method before the return statement that prints out the values of the two variables that are used to compute the value that is returned. Seeing their values could help you see what the code is doing.
    Code:
    System.out.println(<PUT THE VARIABLES HERE WITH +" " + BETWEEN THEM);
    Thanks for the advice and all of your help. I won't be able to compile until I get home (Im at work until 8p) but I will try this and let you know.

    Sorry for being such a noob and thank you for your patience!
  12. #22
  13. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    See you later then.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo