aspose file tools*
The moose likes Beginning Java and the fly likes Divide a vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Divide a vector " Watch "Divide a vector " New topic
Author

Divide a vector

Shaista shaikh
Greenhorn

Joined: Dec 02, 2005
Posts: 2
having a list of person name (suppose 5) want to print those name like 2 , 2 & 1 one by one in java
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47
Pls be clear about what exactly you want to do.
If you have list a list of Names , do you want to hold them in a collection with Name,Value pairs ?
Naveen Verma
Greenhorn

Joined: Jun 05, 2002
Posts: 9
I don't know if u r trying to achive something like this...

List lst = new ArrayList();
lst.add("item_1");
lst.add("item_2");
lst.add("item_3");
lst.add("item_4");
lst.add("item_5");
double group = Math.round(lst.size()/2.0);
int p=0;
for (; p < (group +2); ) {
String str = null;
str = (String)lst.get(p);
if ((p+1) < lst.size())
str = str + " "+ lst.get(p+1);
p = p+ 2;
System.out.println("str="+str);
}

-Naveen
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Let's have this stimulating discussion in Java in General (Beginner).


[Jess in Action][AskingGoodQuestions]
 
jQuery in Action, 2nd edition
 
subject: Divide a vector