1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
/* Java String to String Array Example This Java String to String Array example shows how to convert String object to String array in Java using split method. */ public class JavaStringToStringArrayExample { public static void main(String args[]){ //String which we want to convert to String array String str = "Java String to String Array Example"; /* * To convert String object to String array, first thing * we need to consider is to how we want to create array. * * In this example, array will be created by words contained * in the original String object. So, first element of array * will contain "java", second will contain "String" and so on. * * To convert String to String array, use * String[] split(String delimiter) method of Java String * class as given below. */ String strArray[] = str.split(" "); System.out.println("String converted to String array"); //print elements of String array for(int i=0; i < strArray.length; i++){ System.out.println(strArray[i]); } } } /* Output of Java String to String Array Example would be String converted to String array Java String to String Array Example */ |
how to do this
Student Class
Name
Age
Class
Marks_Science
Marks_Maths
Marks_LanguageI
Marks_LanguageII
Marks_Env
create an array of students
add students
print the details of the student in position 4
print the details of all the students
Find the count of students