Click here to Skip to main content
15,887,874 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
public static void main(String[] args) {
		TestSection ts = new TestSection();
		Section s = new Section();
		String[] str = new String[] { "Jack:90:92:90:90:90",
				"Shazz:88:45:76:60:44", "Nazz:74:44:56:64:52" };
		s = ts.makeSections(str);
		System.out.println(s.nameofA());
	}

	public Section makeSections(String[] studentsData) {
		Section sc = new Section();
		sc.student = new Student[studentsData.length];
		String[] studentsDta = new String[3];
		for (int i = 0; i < studentsData.length; i++) {

			studentsDta = studentsData[i].split(":");
			sc.student[i] = new Student();
			sc.student[i].name = studentsDta[0];
			sc.student[i].marks = studentsDta[];

		}

		return sc;

	}

here sc.student[i].marks is an array i want to store above student marks in it
Posted
Updated 26-Oct-14 0:07am
v2

1 solution

Something like this:
Java
int j;
sc.student[i].marks = new int[studentDTA.length-1];
for (j = 0; j < (studentDTA.length - 1 ); j++)
{
  sc.student[i].marks[j] = integer.parseInt(studentDTA[j+1]);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900