Answers for "how to display the first string in an array"

1

get first letter of string in array java

// Array of names
		String name [] = {"Clark", "Bruce", "Diana", "Barry"};
		
		// for each loop (to iterate everything inside the array)
		for (String firstChar: name) {
			System.out.println(firstChar.charAt(0));
		}

		/* Prints
        	C
            B
            D
            B
        */
Posted by: Guest on February-09-2022

Code answers related to "how to display the first string in an array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language