Hi,

I'm trying to figure out how to implement toString() methods into the JavaTest and H2ClassB classes so that the output would be 4 3 7 5 99 3:

import java.util.ArrayList;

public class JavaTest {
ArrayList <JavaTest> list = new ArrayList <JavaTest> ();



public static void main (String args []) {
JavaTest y = new JavaTest ();
int [] v = {4, 3, 7, 5, 99, 3};
for (int m: v)
y.list.add (new H2ClassB (m));
System.out.println (y);
} // end main

public String toString() { //This is where I thought
return v[1], v[2],..etc. //to put the method but I
} //don't think it's correct

} // end class JavaTest

class H2ClassB {
int x;
H2ClassB (int a) { x = a;}
} // end H2ClassB

Thanks.

Similar Questions
  1. Figure 1: chairFigure 2: tree Figure 3: nut Figure 4: House which scale drawing is a dilation that increases the size of the
    1. answers icon 1 answer
  2. Which figure would result from rotating and dilating Figure 1?(1 point) Responses Figure 2 Figure 2 Figure 3 Figure 3 Figure 5
    1. answers icon 1 answer
  3. Which combination of figures are similar and why?(1 point) Responses 1.Figure 1 and Figure 3; one figure is larger than the
    1. answers icon 7 answers
  4. which combination of figures are similar and whyA.figure 1,figure 2 and figure 3 all figures are rectangles B.figure 2 and
    1. answers icon 1 answer
more similar questions