I'm a Java beginner, and here's my issue : I don't understand why my output is "null" while implemanting my Print program. As I understand my code, it is supposed to display :" http://www.google.com". I tried with a StringBuilder, and I still have this problem. Could someone give me some help please ? Thanks
URL.java :
public class URL {
String url;
public void create(){
url = new String();
url+=("http://www.google.com");
}
public String geturl() {
return this.url;
}
}
Print.java :
public class Print {
public static void main(String[] args) throws Exception {
URL link = new URL();
System.out.print(link.geturl());
}
}
String url = "http://www.google.com";for example.