Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compilation error

 
Pankaj Shet
Ranch Hand
Posts: 300
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
paresh doshi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]);
}
}
 
Pankaj Shet
Ranch Hand
Posts: 300
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still I am not getting it.
 
KartikD Patel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Pls try to Compile this code
 
Pankaj Shet
Ranch Hand
Posts: 300
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still not getting it.
 
Tommaso Nuccio
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the error you have shown does not match the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic