So there is a
Array<Student> called stu
that has 2 student objects in there [0], [1]
One of the elements that Studet[0] has (as well as Student [1]) is
String sid which is equal to "2345"
Studet[0] also has double Q1 = 95.0
1) String ut = stu[0].sid; // Why it does not give me the sid value "2345"?
My goal is to get the sid value of stu[0]?
What are my options here?
Getting Value of an Array Element
Page 1 of 12 Replies - 880 Views - Last Post: 08 October 2012 - 02:54 PM
Replies To: Getting Value of an Array Element
#2
Re: Getting Value of an Array Element
Posted 07 October 2012 - 03:30 AM
Please don't create duplicate threads. Post questions related to your first thread in that thread. As for your question, you should try using a debugger. Without the code in full, there's no way to know what's causing the problem.
If the class Student has a field name sid, and you've got an array of Students named studentArray, then studentArray[0].sid is want you want.
Quote
My goal is to get the sid value of stu[0]?
If the class Student has a field name sid, and you've got an array of Students named studentArray, then studentArray[0].sid is want you want.
This post has been edited by blackcompe: 07 October 2012 - 03:45 AM
#3
Re: Getting Value of an Array Element
Posted 08 October 2012 - 02:54 PM
Is this supposed to be an ArrayList<Student> or a Student[]?
If you're using ArrayList<Student>, you cannot use brackets to retrieve objects, you have to use the get method.
If you're using ArrayList<Student>, you cannot use brackets to retrieve objects, you have to use the get method.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|