Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

I do not know why I am getting the "No suitable method found

$
0
0
Hi, I am trying to learn how to use Java and this is only my third day working with the language and I know next to nothing about the syntax. So if my code looks like it was written by an amateur, that's because it was. I am getting the error message "no suitable method found for add(int,char) method java.util.ArrayList.add(int,java.lang.String) is not applicable; The "add" in the 17th line is being highlighted red when I try to compile the code. Any help would be greatly appreciated.


import java.util.Scanner;
import java.util.ArrayList;

public class numberology {
    public static void main(String[] args) {
        String name;
        int index = 0;
        Scanner in;
        ArrayList<String> nameList = new ArrayList<String>();
        
        in = new Scanner(System.in);
        System.out.println("Enter your name: ");
        name=in.next();
        for(int count=0; count < name.length();count++){
            index++;
            char letter = name.charAt(count);
            nameList.[b]add[/b][/font](index,letter); 
            Object[] elements = nameList.toArray();
            System.out.print(elements[a]);
            
        } 
       // 
       //System.out.println(letter);
        
    }
}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>