writting this :

N = args[1].split("\\s+").length;

with commandline argument like : echo "A B C D E F G H I" | java Subset 3 , will this consume similar memory as would have been the case if i parsed the "A B C D E F G H I" string using .split() into a String array ?

my assingment states that (as a challenge) the student (me) can try to display K strings ( K = 3 in the above cmd line ) uniformly at random , from the N string ( N = 9 above , A to I ) input , while consuming memory proportional to K , and not N.
so thats basically what im trying to do.

answer to my original question is : yes . which i kinda guessed will bethe case anyway.
im reading into this . turns out to be what i need here.

Thread solved i suppose.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.