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

class Arralist{

public static <Cd> void main(String [] args) {

ArrayList<Cd> liste = new ArrayList<Cd>();

try {
Scanner input = new Scanner(new File("text.txt"));

while (input.hasNext()) {
catch (FileNotFoundException e) {

I got error like this :

: error: no suitable method found for add(String)
method ArrayList.add(int,Cd) is not applicable
(actual and formal argument lists differ in length)
method ArrayList.add(Cd) is not applicable
(actual argument String cannot be converted to Cd by method invocation conversion)
where Cd is a type-variable:
Cd extends Object declared in method <Cd>main(String[])
1 error

Process completed.

What wrong how do I fix this

The reason is that the "Cd" class is not a String class. the next() method return a String if I remember correctly. What is your Cd constructor? Possible solution (depending on your Cd constructor) is as follows...

liste.add(new Cd(;