wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Compilation error" Watch "Compilation error" New topic
Author

Compilation error

Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 219

Sir ,
This program does compile.When I try to compile,it gives me
the following error:-

Test18.java:7: not a statement
fl[]= new float[10];
^
Test18.java:7: ';' expected
fl[]= new float[10];
^

public class ArrayTest {
public static void main(String[] args) {
float fl[], f2[];
fl = new float[10];
f2 = f1;
System.out.println(�f2[0]= � + f2[0]);
}
}
I am not able to get the solutions for this,please reply.
-thank you.


PANKAJ SHET
B.Sc.(I.T.), S.C.J.P., S.C.W.C.D., PGDAC(CDAC)
paresh doshi
Ranch Hand

Joined: Nov 20, 2006
Posts: 81
there is the error in code...f1 is written instead of fl;

public class ArrayTest {
public static void main(String[] args) {
float fl[], f2[];
fl = new float[10];
f2 = f1; /// replace f1 with fl.
System.out.println(�f2[0]= � + f2[0]);
}
}


Thanks.<br />Paresh Doshi<br />SCJP 1.4
Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 219

Still I am not getting it.
KartikD Patel
Greenhorn

Joined: Mar 10, 2007
Posts: 2


Pls try to Compile this code
Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 219

I am still not getting it.
Tommaso Nuccio
Ranch Hand

Joined: Dec 11, 2006
Posts: 66
Originally posted by Pankaj Shet:

1--> float fl[], f2[];
2--> fl = new float[10];
3--> f2 = f1;


You define two arrays of floats in line "1-->" as
fl (note that it is "l" like "letter" and not the number "one"!!)
and f2.
Later on line "3-->", you want to reference f2 to f1, but there is no f1, as you defined an array named "fl" (with the "l"etter.)
The compiler does not know an array of floats called "f1"!

That's the mistake.


Ciao,<br /> Tommaso<br /> <br />~*~*~*~<br />There are 10 types of people, those who understand binary and those who don't.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Also the error you have shown does not match the code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compilation error
 
Similar Threads
Assigning Array references
MIN_VALUE of Float & Double class
Doubt in synchronized....
about initialization?
doubt on constructor