Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:35:13+00:00 2026-06-07T08:35:13+00:00

Hello guys im having little problem here, Firstly i want to parse string which

  • 0

Hello guys im having little problem here,
Firstly i want to parse string which comes from scanner into int, so i can later use it IF statement.
Code looks like this

List<String> list = new ArrayList<String>();
    Scanner numbers = new Scanner(System.in);

    do {
        System.out.println("Current list is " + list);
        System.out.println("Add more? (y/n)");

        if (numbers.next().startsWith("y")) 
        {
            if(Integer.parseInt(numbers)> 0 && Integer.parseInt(numbers) < 101)
            {// i get error on above line, and im kinda lost here


                System.out.println("Enter : ");
                list.add(numbers.next());
            }
        }
        else
        {            
            break;                
        }           
    }while (true);

Any help appreciated, hopefully i made my self clear and my problem too

Edit:

        do {

        System.out.println("Current list is " + list);
        System.out.println("Add more? (y/n)");

        if (numbers.next().startsWith("y")) 
        {                               
            System.out.print("Enter: "); 
            System.out.flush();                
            final int n = Integer.parseInt(numbers.next());
            if (n > 0 && n < 101) 
            {
                list.add(n);
                // this is where i get the error.

                //no suitable method found for add(int)
                // method java.util.List.add(int,java.lang.String) is not applicable
                // (actual and formal arguments lists differ in length)
                // method java.util.List.add(java.lang.String) is not applicable
                // (actual argument int cannot be converted to java.lang.String 
                // by method invocation conversion).

                // end of log
            }
            else
            {
                System.out.println("Number you have entered exceeds raange between 0-100");
            } 
        }
        else
        {            
            break;                
        }           
    }while (true);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:35:14+00:00Added an answer on June 7, 2026 at 8:35 am

    I presume you wanted to write

    System.out.print("Enter: "); System.out.flush();
    final int n = Integer.parseInt(numbers.next());
    if (n > 0 && n < 101) list.add(n);
    

    java.util.Scanner also contains the method nextInt, which obviates the need for Integer.parseInt. You can just say numbers.nextInt().

    You also need to change your list declaration from List<String> to List<Integer>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys Im having a problem in how to clear the previous activity after
Hello guys i'm having one hell of a time trying to parse an xml
Hello guys am having a problem with downloading modules. Anytime i try to download
Hello Guys! I am going to write website crawler, which starts from root address
Hello guys i have a little problem i get an error: File C:\Users\kokki\Desktop\gb1\main.py, line
Hello guys i've been having a problem with Mathematica 8.0. When i export my
hello guys im having problems with Internet Explorer positioning (as usual...) the problem is
hello guys I am trying to extract all the anchor links from aol but
Hello guys can anyone help me with the issue im having with installation of
Hello guys I need to pass a string array over to a setter that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.