java - If statement not changing initialized value -
My enum type is not being replaced with its default "null" value when displayed by an original toString method. When the user inputs JPG, GIF, etc. then the event statement matches the entry. If the statement is not taking the input of the user and converts it to an aanan?
public static zero process photo () {string value; String size; String name; String straight type; Double Dies; String photographer; Int iValue = 1; Scanner KB = new scanner (System.in); While (iValue> 0) {System.out.print ("Enter the name of the photo"); Name = kb.nextLine (); System.out.print ("Enter the type of photo (JPG, GIF, PNG, BMP, or others).); StrType = kb.nextLine (); StrType = strType.toUpperCase (); If (strType == "JPG") {type = Type.JPG;} If (strType == "GIF") {type = Type.GIF;} If (strType == "PNG") {type = Type.PNG;} If (straight typed == "BMP") {type = Type.BMP;} If (strType == "Other") {type = Type.OTHER;} System.out.print ("\ nEnter the size of the photo (in megabytes)" ); Size = kb.nextLine (); DSize = Double .prsd double (size); System.out.print ("\ nFor the photographer of the photo"); photographer = KB.NXTain (); photo p = new Photo (na , Type, decise, photographer); System.out.print (p.toString ()); System.out.print ("\ n \ nEnter the zeros more than zero to continue." Finish the ZERO. " ); Value = kb.nextLine (); IValue = integer Parasite (value);}}
Compare the wire instead of this approach.
If (strType.equals ("JPG")) then you use the same string Let's compare two strings for.
== Compares that two strings are actually stored in the same object memory, of which they are not.
Comments
Post a Comment