File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Divide a vector

Shaista shaikh

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

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

List lst = new ArrayList();
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;

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

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

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Divide a vector
It's not a secret anymore!