java indexof array

https‮l.www//:‬autturi.com
java indexof array

find out the index of an element in array:

/**
 * @author lautturi.com 
 * Java example: how to get the element index in java array
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {
		
		String[] strArray = {"java","python","perl","js","perl","c","go"};
		String str = "js";
		int idx = Arrays.asList(strArray).indexOf(str);
		
		System.out.println("The index of js element is "+idx);
	}
}

output:

The index of js element is 3
Created Time:2017-09-25 01:54:29  Author:lautturi