java - Input from a file (Find the nth element for the Linked List) -


the problem find nth element in linked list, have problem figured out on finding element.

but have read input file , output nth element list

for example

input  b c d 4 e f g h 2  output g 

it stated "the first argument path filename containing series of space delimited characters followed integer representing index list (1 based), 1 per line"

i not sure how go this? first read file , store each line in list?

yes, should read file line line, , store each line in list<string>. then, this:

string line; // use iterator on list each line string[] elements = line.trim().split("\\s"); char[] chars = new char[elements.length - 1]; int index = integer.parseint(elements[elements.length - 1]); (i = 0; < elements.length - 1; i++)     char[i] = elements[i].charat(0); 

now have characters in array ... , said have rest figured out.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -