Hello All, I am trying to parse a string to an int with the following code: Integer pa = Integer.parseInt(txtAudio.getText()); When I complie the code I get the following error:
Quote.java:101: incompatible types found : int required: java.lang.Integer Integer pa = Integer.parseInt(txtAudio.getText()); ^ I have import the java.lang.Integer class and that did not fix the error. Thanks for your help Stacey
You don't need to import java.lang.Integer, as every class in java.lang is implicitly imported. The message is telling you that this method returns "int", but you're assigning the result to an Integer. "Integer" is a kind of object, while "int" is a primitive type. You most likely watt to use "int" here instead -- i.e., pa should be an int, not an Integer. If you really do want pa to be an Integer, then parseInt is the wrong method to call -- use "new Integer(txtAudio.getText())" instead.