Share
Explore BrainMass

Trouble Shooting C++ Code

This code prints all elements of the array geo
for ( int i = 0; i < geo.length; i++ )
{
//the code is missing here

}
__________________________________________________________________
Where is the error in this code sequence?
// a is an ArrayList of strings
// a has already been declared and instantiated
a.size ( ) = 10;
________________________________________________________________

You coded the following in the Test.java class:
public static void main (string) [ ] args)
{
// cars is an ArrayList of Auto Objects
// cars has already been declared and instantiated
for ( Auto a ; cars ) // line 12
{
System.out.println (a. to string ( ) );
} // line 15
} //line 16
When you compile, you get the following message:
Test.java:12 '; 'expected
for ( Auto a ; cars ) // line 12
^
1 error
Explain what the problems are and how to fix them.

Solution Preview

1.
This code prints all elements of the array geo
for ( int i = 0; i < geo.length; i++ )
{
for (int j=0; j<geo[i].length; j++)
System.out.println(geo[i][j]);
}

2.
a.size () is illegeal method. The right code ...

Solution Summary

The solution fixed some errors or add some code using c++ language. All errors are explained.

$2.19