Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

why inifinity code

Name: Anonymous 2016-07-06 10:14

Hello sirs im using the list Java and I am using the iterating collection to do the work with the list Why code is the infinity?

int i = 0;
int j = 0;

List<Integer> li = new ArrayList<Integer>();

for (i = 0; i < 10; i++) {
li.add(i);
}

do {
System.out.println(li.get(j));
} while(j < li.size());

Name: Anonymous 2016-07-06 19:20

// AbstractSingletonBeanConsFactory.java
template <typename T>
class AbstractSingletonListConsFactory {
// TODO lookup how to do templates in Java
public static void cons(T x, List<T> xs) {
xs.add(0, x);
return xs;
}
}

// InfinityCodeBean.java
class InfinityCodeBean {
private static List<Integer> fillList(Integer upto) {
if (upto < 0) {
return new ArrayList<Integer>();
}
return AbstractSingletonListConsFactory::cons(upto, InfinityCodeBean::fillList(upto-1));
}
public static void infinitize() {
ArrayList<Integer> lst = InfinityCodeBean::fillList(10);
while (1) {
System.out.println(lst.get(0));
}
}
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List