your correct answer looks like this :
for(String[] row : table)
{ System.out.print(row[row.length-1]); }
you have omitted one bracket ...
About Question enthuware.ocajp.i.v7.2.1400 :
Moderator: admin
-
- Posts: 6
- Joined: Mon Feb 23, 2015 9:37 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1400 :
Very sorry, but it looks ok to me 

-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1400 :
When I try to run this program I get these errrors:
Errors:
Why the errors here?
Code: Select all
public class Test{
static String[][] table;
public static void main(String[] args) {
String[] x = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
String[] y1 = { "1", "2", "3", "4", "5" };
String[] y2 = { "a", "b", "c" };
table = new String[3][];
table[0] = x;
table[1] = y1;
table[2] = y2;
for(int i=0; i<table.length-1; i++) {
int j = table[i].length-1;
System.out.print(table[i][j]);
}
}
}
Code: Select all
Test.java:14: error: illegal character: '\u00a0'
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: not a statement
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: illegal character: '\u00a0'
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: not a statement
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: illegal character: '\u00a0'
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: not a statement
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: illegal character: '\u00a0'
for(int i=0; i<table.length-1; i++) {     
^
Test.java:14: error: not a statement
for(int i=0; i<table.length-1; i++) {     
^
Test.java:15: error: illegal character: '\u00a0'
int j = table[i].length-1;     
^
Test.java:15: error: not a statement
int j = table[i].length-1;     
^
Test.java:15: error: illegal character: '\u00a0'
int j = table[i].length-1;     
^
Test.java:15: error: not a statement
int j = table[i].length-1;     
^
Test.java:15: error: illegal character: '\u00a0'
int j = table[i].length-1;     
^
Test.java:15: error: not a statement
int j = table[i].length-1;     
^
Test.java:15: error: illegal character: '\u00a0'
int j = table[i].length-1;     
^
Test.java:15: error: not a statement
int j = table[i].length-1;     
^
16 errors
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1400 :
Delete those junk chars.
Or, instead of selecting the code on the question screen through mouse, do a right click on it and the select Copy Source menu item.
Or, instead of selecting the code on the question screen through mouse, do a right click on it and the select Copy Source menu item.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1400 :
aha I see. I just coundt see those charachters in my text editor.
- Attachments
-
- Capture.PNG (59.51 KiB) Viewed 1849 times
Who is online
Users browsing this forum: No registered users and 5 guests