Results 1 to 4 of 4
Thread: list problem
- 06-27-2007, 11:46 AM #1
Member
- Join Date
- Jun 2007
- Posts
- 2
- Rep Power
- 0
list problem
let say i have a lists of name
michael
john
sarah
then i put it into array
User userList[] =new User[];
then i create loop to print that list
for (int i=0; i<userList.length; i++;){
listbox1.setItems(userList[i]);
anybody know how to modified this code if want to test every name if it have a condition like this:
michael is resident for apartement A
john n sarah are resident for apartment B
so i think i want to use if..else but i don't know how to code that..plz anybody help me...
- 06-27-2007, 05:38 PM #2
hi fareez,
Please put your code inside [code] tags next time. That will be easier to read and correctly printed on the page.
Regarding your question:
You can keep two other integer arrays, one for apartment A and one for apartment B.
And assign index of each of your users to this arrays. So if "Michael is resident for apartment A" and index of Michael in userList is 1, then write the following in your initialization code:
Then for this query: "is michael resident for apartement A", you will search apartementA array for the index of michael which was 1. If you find that, return true else false.Java Code:apartmentA[0] = 1;
Let me know if something is unclear.
- 06-28-2007, 04:19 AM #3
Member
- Join Date
- Jun 2007
- Posts
- 2
- Rep Power
- 0
i already write a code like this.Is my coding right?:
Java Code:PropertyInfo pInfo = PropertyInfoDAO.loadPropertyInfoByORMID(this.getSessionBean1().getPropertyID()); User[] userList = UserDAO.listUserByQuery(null,null); Option[] optUser = new Option [userList.length]; int y = 0; for (int i=0; i<userList.length; i++){ if (userList[i].inCharge.contains(pInfo)){ [CENTER]//condition[/CENTER] else { [CENTER]//condition[/CENTER]
i query apartment id using below code:
Actually i have 2 pages which is the previous page have a list of apartment.I create link for apartment name,then when i click that link,such as i click link for apartment A,it will go to the next page which contains a residents list for apartment A.Java Code:PropertyInfo pInfo = PropertyInfoDAO.loadPropertyInfoByORMID(this.getSessionBean1().getPropertyID());
I put resident list in listbox component.I use 2 listboxes. I name it listbbox1 and listbox2.If michael is resident for apartment A,his name will appear in listbox1 and john and sarah will appear in listbox2 because they are not resident for aparment A.
The case is same for apartment B. Sarah and Michael will appear in listbox1 but michael will appear in listbox 2 becase michael is not resident for apartmentB
- 06-28-2007, 10:26 AM #4
Similar Threads
-
List and ArrayList
By ravian in forum New To JavaReplies: 3Last Post: 07-27-2011, 05:05 PM -
Members List
By Eranga in forum Suggestions & FeedbackReplies: 11Last Post: 01-17-2008, 10:41 AM -
Array List Problem
By khamuruddeen in forum New To JavaReplies: 1Last Post: 12-22-2007, 08:10 AM -
list
By Zensai in forum New To JavaReplies: 3Last Post: 11-20-2007, 07:22 AM -
How to get the max value from a list
By osval in forum New To JavaReplies: 1Last Post: 07-30-2007, 05:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks