1 Replies - 198 Views - Last Post: 06 July 2013 - 09:19 PM Rate Topic: -----

#1 jamescruz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-July 13

Java Error :"Local variable __ is never read"

Posted 06 July 2013 - 08:00 PM

hello guys, i need some help... im writing a java code about conversion of a string to its integer partner. (e.g. "one" to 1) my problem is that i the local variable "ones" in my code is never read.. i cannot find any problems with the algo itself, but i think. its all about the syntax... -_-.... any answers will be appreciated... thanks!
public static void convert (String str) {
		int ones;
		if(str=="one") 
			ones = 1;
		else if(str == "two")
			ones = 2;
		else if(str == "three")
			ones = 3;
		else if(str == "four")
			ones = 4;
		else if(str == "five")
			ones = 5;
		else if(str == "six")
			ones = 6;
		else if(str == "seven")
			ones = 7;
		else if(str == "eight")
			ones = 8;
		else if(str == "nine")
			ones = 9;
		else {
			System.out.println("Wrong input!");
			System.exit(1);
		}
		System.out.println(ones);
	}


Is This A Good Question/Topic? 0
  • +

Replies To: Java Error :"Local variable __ is never read"

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,246
  • Joined: 27-December 08

Re: Java Error :"Local variable __ is never read"

Posted 06 July 2013 - 09:19 PM

Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1