arrays - Storing a string and two doubles java -
i have written programme gives me 3 arrays.a string array , 2 dole arrays.... want save them in 1 thing(i don't know if array or matrix).....
forexample: have file read , input like:
apple 2.3 4.5 orange 3.0 2.1 pear 2.9 9.6 etc......
i made 3 arrays, 1 stores name of strings , other 2 stores 2 columns of doubles...
but want store whole row "(apple 2.3 4.5)" in 1 thing if want find apple related values of apple..... can please guys give me hint how can that? thought of having 3 diminutional array not figure out how initialise because have 1 string value , 2 doubles......
i have no clue do.... help highly appreciated.... in advance.
a nice generic solution:
public class triple<l, k, v> { private final l first; private final k second; private final v third; public triple(l first, k second, v third) { this.first = first; this.second = second; this.third = third; } public l getfirst() { homecoming this.first; } public k getsecond() { homecoming this.second; } public v getthird() { homecoming this.third; } }
which can implemented such:
triple<string, integer, integer> mytriple = new triple<>("hello world", 42, 666);
but real concept here representing point of info object in code. if have set of info ("i have string , 2 ints mean something"), want encapsulate under single class.
java arrays
No comments:
Post a Comment