Skip to content

Instantly share code, notes, and snippets.

@t-botz
Created April 22, 2011 13:31
Show Gist options
  • Save t-botz/936656 to your computer and use it in GitHub Desktop.
Save t-botz/936656 to your computer and use it in GitHub Desktop.
package jug;
import java.net.MalformedURLException;
import java.net.URL;
public class Initializer {
static class A{
protected String myString;
A(String rawString){
myString = veryComplexTransformation(myString);
}
A(Integer i){
myString = "'"+i.toString()+"'";
}
A(Object o){
myString = o.toString();
}
private String veryComplexTransformation(String str) {
return str.toLowerCase();
}
}
static class B extends A{
private final URL u;
{
String url = "http://wwww.google.fr/search?q="+myString;
try {
u =new URL(url);
} catch (MalformedURLException e) {
throw new ExceptionInInitializerError("WTF!");
}
}
public B(Integer i) {
super(i);
}
public B(String rawString) {
super(rawString);
}
public B(Object o) {
super(o);
}
public URL getU() {
return u;
}
}
public static void main(String[] args) {
System.out.println(new B(2).getU());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment