Search code examples
javaparseint

ParseInt Error - Java


Why am I getting this error? I've tried changing many aspects of the code, but could not figure out the error. Thank you!

import java.util.*;


public class Problem1
{
    public static void main(String[] args)
    {
        int ogarank = 177;
        int ogbrank = 129;
        int ogcrank = 11;
        int newarank = 0;
        int newbrank = 0;
        int newcrank = 0;
        int input = 0;
        Scanner scan = new Scanner(System.in);

        System.out.println("Enter Your Number");
        input = scan.nextInt();

        input = input % 100;
        newcrank = separate(input, newcrank);
        input = input % 100;
        newbrank = separate(input, newbrank);
        input = input % 100;
        newarank = separate(input, newarank);

    }

    public static int separate(int input, int rank)
    {
        rank = input;
        return rank;
    }

    public static int convert(int ogrank)
    {
            int digit1;
            int digit2;
            String convert;
            digit1 = ogrank / 10;
            digit1 = digit1 * 16;
            digit2 = ogrank % 10;
            digit2 = digit2 * 1;
            convert = ("" + digit1 + "" + digit2 + "");
            ogrank = convert.parseInt();
    }

error: cannot find symbol

        ogrank = convert.parseInt();
                        ^

symbol: method parseInt()

location: variable convert of type String


Solution

  • The method is Integer.parseInt()

    convert is a String type variable and doesn't have parseInt() method