Hello I am trying to build a simple program that converts a string containing a number into an integer. I am receiving the error on the System.out.println and not sure why, can anyone help?
public class TypeConvert {
int strToInt;
public int convert (String s){
strToInt = Integer.parseInt(s);
return strToInt;
}
public static void main(String[] args) {
String strNumber=("100");
TypeConvert convertToInt = new TypeConvert();
convertToInt.convert(strNumber);
System.out.println(strToInt);
}
}
This has been marked as duplicate so I am editing. I did actually read all the relevant posts to my problem but as I did not understand how to fix my problem with theirs I created my own post.