whughesiii
MIS
Hey all,
I have some experience with programming with Perl, PHP and a tiny bit of C++. I am trying to teach myself Java. Of course the book I am using doesn't have solutions to the exercises with explanations at all. On one exercise it says to take bits of code from the examples and make them into a program that compiles and runs. I believe I have it right, but as I am a beginner I probably am missing something. I have a file called Exercise4.java and the code is as follows:
However when I compile it, I get these errors:
What am I doing wrong?
I have some experience with programming with Perl, PHP and a tiny bit of C++. I am trying to teach myself Java. Of course the book I am using doesn't have solutions to the exercises with explanations at all. On one exercise it says to take bits of code from the examples and make them into a program that compiles and runs. I believe I have it right, but as I am a beginner I probably am missing something. I have a file called Exercise4.java and the code is as follows:
Code:
//: Exercise4.java
public class Exercise4
{
class DataOnly
{
int i;
double d;
boolean b;
}
DataOnly data = new DataOnly();
data.i = 47;
data.d = 1.1;
data.b = false;
}
However when I compile it, I get these errors:
Code:
Exercise4.java:13: <identifier> expected
data.i = 47;
^
Exercise4.java:14: <identifier> expected
data.d = 1.1;
^
Exercise4.java:15: <identifier> expected
data.b = false;
^
3 errors
What am I doing wrong?