Question : Unresolved Compilation Problem in Java

I'm compiling in Eclipse on a Mac...I'm kind of new to Eclipse, and i'm having a problem.

I have gotten other programs to run, and I'm well versed in C/C++, but now I don't even get a proper error and I'm not sure why.  I've pasted the code below, the exact error I'm getting is:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at ShortCodeExamples.main(Snippets.java:108)


---

Let me know what I'm doing wrong?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
//imports
 
 
import java.awt.Rectangle;
 
 
/**
 
 * Contains 30 small code snippets for a review of Java syntax, variables,
 
 * and expressions
 
 */
 
 
public class ShortCodeExamples {
 
 
 
/**
 
* main method with the 30 code snippets. Execute main after commenting
 
* out snippets that have syntax errors to see the results.
 
* @param  args  not used
 
*/
 
public static void main(String[] args) {
 
/* For each of the following snippets of code answer these 3 questions.
* 1. Record what you expect the output to be.
* Do this before you run the program.
* 2. Run the program and record what the output actually was.
* 3. Provide a brief explanation the actual output.
* If there is a difference between you expected answer and the
* actual answer that is okay! Include in your explanation what
* you didn't understand about the code. If a snippet would
* result in a syntax or compile error then the expected result
* is "syntax error" or "compile error". If the code causes a
* syntax or runtime error explain why the error occurred. You
* do not have to explain how to correct the error.
*/
 
 
// Number 1
int x1 = 17 / 5 + 2;
System.out.println(x1);
 
// Number 2
int x2 = 31 % 5 + 31 % 6;
System.out.println(x2);
 
// Number 3
double a3 = 17.0 / 5.0 + 2.0;
System.out.println(a3);
 
// Number 4
double a4 = 17 / 5.0 + 2.0;
System.out.println(a4);
 
// Number 5
double a5 = 17 / 5 + 2.0;
System.out.println(a5);
 
// Number 6
double a6 = 17 / 5.0 + 2;
System.out.println(a6);
 
// Number 7
double a7 = 3 / 2 + 6 / 5;
System.out.println(a7);
 
// Number 8
double a8 = 5 / 3 * 2.0 / 3;
System.out.println(a8);
 
// Number 9
double a9 = 5.0 % 3.0;
System.out.println(a9);
 
// Number 10
int x10 = 2147483647;
int y10 = 1;
int z10 = x10 + y10;
System.out.println(z10);
 
// Number 11
double a11 = 11.00;
double b11 = 10.09;
double c11 = a11 - b11;
System.out.println(c11);
 
// Number 12
double a12 = 1000000000;
double b12 = 0.00000001;
double c12 = a12 - b12;
System.out.println(c12);
 
// Number 13
int x13 = 3;
int y13 = 4;
y13 += x13 * y13;
System.out.println(y13);
 
// Number 14
int x14 = 5;
int y14 = 3;
y14 *= y14 + x14;
System.out.println(y14);
 
// Number 15
int x15 = 3;
x15++;
++x15;
x15 = x15 + 1;
x15 += 1;
System.out.println(x15);
 
// Number 16
int x16 = 4;
x16++; // Okay
System.out.println(x16);
++x16; // Okay
System.out.println(x16);
int x16_1 = 3;
int x16_2 = 3;
x16 = x16_1+++x16_2; //Absolutely horrible style.
System.out.println( x16 + " " + x16_1 + " " + x16_2 );
 
// Number 17
int x17 = 5;
System.out.println(++x17);
System.out.println(x17++);
System.out.println(x17);
 
// Number 18
/*int x18 = 5;
if( x18 = 5)
System.out.println("variable x18 equals 5");*/
 
// Number 19
int x19 = 12;
int y19 = 6 * 2; //12
Rectangle box191 = new Rectangle(200, 100, 5, 10);
Rectangle box192 = new Rectangle(200, 100, 5, 10);
boolean same191 = ( box191 == box192);//true
boolean same192 = ( box191.equals(box192) );//true?
boolean same193 = (x19 == y19);
System.out.println(same191);
System.out.println(same192);
System.out.println(same193);
 
// Number 20
/*int x20 = 0;
double a20 = 1.5;
x20 = a20;
System.out.println(x20);*/
 
// Number 21
int x21 = 12;
double a21 = x21;
System.out.println(a21);
 
// Number 22
int x22 = 0;
double a22 = -1.9;
x22 = (int)a22;
System.out.println(x22);
 
// Number 23
double a23 = 1.5;
double b23 = Math.rint(a23);
System.out.println(b23);
double c23 = 2.5;
double d23 = Math.rint(c23);
System.out.println(d23);
 
/* Number 23. It is not important that you know what the Math.rint
* method does. Rather this question forces you to look up a method
* in the Java standard library documentation, an invaluable skill.
*
* In addition to the answer to the standard 3 questions, answer the
* following for number 23. The Math class is used, but the
* statement import java.lang.Math; does not appear at the top of
* this program. Why doesn't this cause a syntax error?
*/
 
// Number 24
int x24 = 10;
int[] list24 = new int[10];
for(int i = 0; i < list24.length; i++)
list24[i] = i * i * (int)Math.pow(-1, i);
System.out.println( list24[7] );
System.out.println( list24[10] );
 
// Number 25
int[] list25 = {4, 4, 11, 0, 3};
int result = list25[ list25[ list25[2] % list25[1] ] ];
System.out.println( result );
 
// Number 26
Rectangle box26;
box26.setSize(25, 75);
System.out.println( box26.toString() );
System.out.println( box26 );
 
// Number 27
// remember, predict the result BEFORE running the code!
 
String s26 = "We are a \"work for the night is coming.\" culture.";
String s261 = s26.substring(25);
String s262 = s26.substring(10, 15);
System.out.println( "s261: " + s261);
System.out.println( "s262: " + s262);
 
// Number 28. method mustang(int, iny) is shown after main
mustang(2, 3);
//Number 29. method mustang(int) is shown after main
mustang(13);
 
//Number 30. method bobcat is shown after main
bobcats(5, 2);
} //end of method main
 
/**
* a "toy code" method to illustrate behaviors of methods and parameters
*/
 
public static void mustang(int x, int y) {
x = x + 3;
y = y - x;
System.out.println( x + " " + y);
}//end of method mustang(int, int)
 
/**
* a "toy code" method to illustrate behaviors of methods and parameters
* @param  a  != 0
*/
 
 
public static int mustang(int a) {
int x = 3 * a;
a = a % 7;
System.out.println( a + " " + x );
return a;
}//end of method mustang(int, int)
 
/**
* a "toy code" method to illustrate behaviors of methods and parameters
* @param  x  != 0
*/
 
public static int hornedFrogs(int x) {
int y = mustang( x );
System.out.println( x + " " + y );
mustang(x, y);
System.out.println( x + " " + y );
return y + x;
}//end of method hornedFrogs
 
/**
* a "toy code" method to illustrate behaviors of methods and parameters
* @param  b  != 0
* @param  C  != 0
*/
public static void bobcats(int b, int c) {
System.out.println(b + " " + c);
int d = mustang(b);
b = b - 3;
c = hornedFrogs( c );
System.out.println(b + " " + c + " " + d);
}// end of method bobcats
 
 
}// end of class ShortCodeExamples

Answer : Unresolved Compilation Problem in Java

initialize this

// Number 26
Rectangle box26;


something like

// Number 26
Rectangle box26 = new Rectangle();

try with this
Random Solutions  
 
programming4us programming4us