run time error in java...... please help......

class Array1

{

public static void main(String args[])

{

double nums[]={10.1,11.2,2.3,13.4,2.5};

double result=0;

int i;

for(i=0;i<5;i++)

result=result+nums;

System.out.println("average is :" + result/5);

}

}

E:\raghav>javac Swingdemo.java

E:\raghav>java Swingdemo

Exception in thread "main" java.lang.NoClassDefFoundError: Swingdem

please reply

i have set the class path also correctly in environment variables.....

regards,

R.Raghavan

[561 byte] By [raghavjavaa] at [2007-11-27 11:40:11]
# 1

1. Your class is named Array1, so it should be defined in a file named Array1.java, not Swingdemo.java

2. You will want to access each element of the array like this:

for(i=0;i<5;i++)

result=result+nums[i];

Time_Agentessa at 2007-7-29 17:30:28 > top of Java-index,Java Essentials,New To Java...
# 2

same error is occuring while running

class Array1

{

public static void main(String args[])

{

double nums[]={10.1,11.2,2.3,13.4,2.5};

double result=0;

int i;

for(i=0;i<5;i++)

result=result+nums;

System.out.println("average is :" + result/5);

}

}

E:\raghav>javac array1.java

E:\raghav>java Array1

Exception in thread "main" java.lang.NoClassDefFoundError: Array1

raghavjavaa at 2007-7-29 17:30:28 > top of Java-index,Java Essentials,New To Java...
# 3

same error is occuring while running

class Array1

{

public static void main(String args[])

{

double nums[]={10.1,11.2,2.3,13.4,2.5};

double result=0;

int i;

for(i=0;i<5;i++)

result=result+nums;

System.out.println("average is :" + result/5);

}

}

E:\raghav>javac array1.java

E:\raghav>java Array1

Exception in thread "main" java.lang.NoClassDefFoundError: Array1

raghavjavaa at 2007-7-29 17:30:28 > top of Java-index,Java Essentials,New To Java...
# 4

E:\raghav>javac array1.java

You are attempting to compile array1.java, but your file and class are Array1.java. Java is case sensitive.

Time_Agentessa at 2007-7-29 17:30:28 > top of Java-index,Java Essentials,New To Java...