Created
April 22, 2011 13:31
-
-
Save t-botz/936656 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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