Java Java Basics Perfecting the Prototype Parsing Integers

Elvis Pilaids
Elvis Pilaids
199 Points

Bummer help

Bummer: java.lang.NumberFormatException: For input string: "answerToLife" ()

Can someone help please?

ParsingInts.java
String answerToLife = ("42");
int answer = Integer.parseInt("answerToLife");

1 Answer

Stanley Thijssen
Stanley Thijssen
22,831 Points

You are not passing the variable answerToLife to the parseInt() method. You have to get rid of the (" ") quotes around your Integer.parseInt("answerToLife"); so it should look like Integer.parseInt(answerToLife);

Hope that helps :)

Elvis Pilaids
Elvis Pilaids
199 Points

int answer = Integer.parseInt (ThankYouVeryMuch);