Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to get elements by index java

ArrayList<String> list = //List instance
 
String firstElement = list.get(0);         
String sixthElement = list.get(5);       
Comment

get index of element java

// if you're too lazy to do anything fancy
// here's a code snippet for ya

// replace 'TYPE' with whatever type your using
// like 'int' or 'String' for example
public static int indexOf(TYPE[] arr, TYPE element)
{
	for (int index = 0; index < arr.length; index++)
    {
    	if (arr[index] == element)
          	return index;
      	else break;
    }
  	
  	// the '-1' is the unique value to
  	// inform you that no element was found
  	return -1;
}
Comment

get index of element in array java

System.out.println(new String(list).indexOf("e")); 
Comment

PREVIOUS NEXT
Code Example
Java :: how to reverse a number in java 
Java :: comentario java 
Java :: java list of arrays 
Java :: center textview programmatically android 
Java :: java end scripting 
Java :: for java 
Java :: java multiple catch blocks 
Java :: distance point to line java 
Java :: java program to find the power of a number 
Java :: java set value of arraylist 
Java :: pre increment and post increments 
Java :: apache csv get headers 
Java :: java foreach backwards 
Java :: how to check number format exception in java 
Java :: sorting list in java 
Java :: how to subtract localdatetime in java 
Java :: binary to octal conversion java program 
Java :: word count in a string using HashMap Collection 
Java :: java php object 
Java :: BottomNavigationView only icon 
Java :: infinite for loop java example 
Java :: hibernate in spring boot 
Java :: get index of element in array java 
Java :: declare a hashmap in java 
Java :: print symbol in pyramid shape in java 
Java :: how to read text file as variable in java 
Java :: java lambda expressions 
Java :: java protected keyword 
Java :: setter getter array java 
Java :: Java List Add Elements using add() method 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =