Java first steps problem with URL don't want to compile BlueJ | Coursera Community
Coursera Header
Solved

Java first steps problem with URL don't want to compile BlueJ

  • 27 August 2019
  • 2 replies
  • 87 views

Badge +1
Hello mine code in BlueJ don't want to compile URL links there are red underlines all the times I'm trying hard but no progress so far pls for help.

Here is a code:

public class URLResource {

String result="";
URLResource ur = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");
for (String word : ur.words()) {
}
}
icon

Best answer by NeilJ 27 August 2019, 18:02

I see a few issues here:

1) as Douglas says, the 'for' loop needs to be inside some method
2) you are constructing a new URLResource with a single param constructor but you have not defined any constructors, so only the default (no-arg) constructor will exist
3) the 'for' loop refers to a ur.words() method, but that method doesn't exist
View original

2 replies

Badge +1
I think you need a main(). If class URLResource is not your main class then you need the for loop inside a method.
Badge
I see a few issues here:

1) as Douglas says, the 'for' loop needs to be inside some method
2) you are constructing a new URLResource with a single param constructor but you have not defined any constructors, so only the default (no-arg) constructor will exist
3) the 'for' loop refers to a ur.words() method, but that method doesn't exist

Reply