Hi
Can anyone help with this problem I would like to have a key associated with one of the values contain in the ArrayList Now I thought I could use the get() Method test.get( 0 ) but it seems that I cant use this Help would be appreciated
Prints this
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
However I would like it to print this
Test Numbers Contain in Map: [0.5]
Test Numbers Contain in Map: [0.7]
Test Numbers Contain in Map: [0.24]
Test Numbers Contain in Map: [9.78]
Can anyone help with this problem I would like to have a key associated with one of the values contain in the ArrayList Now I thought I could use the get() Method test.get( 0 ) but it seems that I cant use this Help would be appreciated
public void test()
{
ArrayList< Float >test = new ArrayList< Float >();
test.add( 0.5f );
test.add( 0.7f );
test.add( 0.24f );
test.add( 9.78f );
Map< Integer, ArrayList< Float > >test1 = new HashMap< Integer, ArrayList< Float > >();
for( int i = 0; i < test.size(); i++ )
{
test1.put( i, test );
}
for( int y = 0; y < test1.size(); y++ )
{
System.out.println( "Test Numbers Contain in Map: " + test1.get( y ) );
}
}
Prints this
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
Test Numbers Contain in Map: [0.5, 0.7, 0.24, 9.78]
However I would like it to print this
Test Numbers Contain in Map: [0.5]
Test Numbers Contain in Map: [0.7]
Test Numbers Contain in Map: [0.24]
Test Numbers Contain in Map: [9.78]