How do I make a Java Input ignore % 's? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I make a Java Input ignore % 's?

Using Scanner in = new Scanner (System.in); int p = in.nextInt(); I want the user to input a % sign but how do I make the Java ignore the percent sign and just get the int data?

26th Sep 2018, 7:26 PM
Noah Garza
Noah Garza - avatar
1 Answer
+ 3
the user provides String data, and you have to work out the data in such a way that you can replace String with an int tip string.replaceAll("%",""); Integer.parseInt();
26th Sep 2018, 8:10 PM
Daniel (kabura)
Daniel (kabura) - avatar