List<String> list1 = new ArrayList <String> ();
		list1.add("One");
		list1.add("Two");
 
		Scanner input = new Scanner(System.in);
		System.out.print("Input the index value of the object required : ");
		int i = input.nextInt();
		boolean b = list1.contains(i);
 
		if(b == true) {
 
			String str1 = list1.get(i);
			System.out.println("The value is : " + str1);
 
		}else {
 
			System.out.println("Index not found");
 
		}
 
		System.out.println("............................");
 
		input.close();

when i input 0 or 1, or any number, my value of b is false..
it's supposed to be true in case if i input 0 or 1..

WHY ???

--- Update ---

Quote Originally Posted by smartshahezad View Post
 
List<String> list1 = new ArrayList <String> ();
		list1.add("One");
		list1.add("Two");
 
		Scanner input = new Scanner(System.in);
		System.out.print("Input the index value of the object required : ");
		int i = input.nextInt();
		boolean b = list1.contains(i);
 
		if(b == true) {
 
			String str1 = list1.get(i);
			System.out.println("The value is : " + str1);
 
		}else {
 
			System.out.println("Index not found");
 
		}
 
		System.out.println("............................");
 
		input.close();

when i input 0 or 1, or any number, my value of b is false..
it's supposed to be true in case if i input 0 or 1..

WHY ???
i think i figured it out.. its because the contains method checks for the particular object and not the index... oops my bad.. thanks anyways guys.. appreciate it..