i typed the following code :
import java.util.*;
class Somethin{
public static void main(
String args[])
{
ArrayList ar = new ArrayList();
ar.add(new Integer(2));
ar.add(new Integer(3));
ar.add(new Integer(5));
ar.add(new Integer(7));
ar.add(new Integer(9));
Object m[] = ar.toArray();
int sum=0;
for(int i=0;i<m.length;i++)
sum+=((Integer)m[i]).intValue();
System.out.println("The sum is:"+sum);
}
}
However it is not compiling properly.I have no idea what is happening when i give the Compile command: javac
But i get the following messages (just a few sample lines)
.\Object.java:67: 'class' or 'interface' expected
<SCRIPT type="text/javascript">
^
.\Object.java:67: 'class' or 'interface' expected
<SCRIPT type="text/javascript">
^
.\Object.java:70: unclosed character literal
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B>
</A>');
^
.\Object.java:70: unclosed character literal
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B>
</A>');
^
.\Object.java:102: <identifier> expected
<DT>public class <B>Object</B></DL>
^
.\Object.java:105: '{' expected
Class <code>Object</code> is the root of the class hierarchy.
^
.\Object.java:105: '{' expected
Class <code>Object</code> is the root of the class hierarchy.
^
Can NEone please help me out here.I tried solving this for two days now ,but to no avail.
Thanks a lot.