Created
August 4, 2017 14:54
-
-
Save joshskeen/ed3f87426bf0588c47c9224143ebdfac to your computer and use it in GitHub Desktop.
horrid names in kotlin <--> java
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
public class `Pizza Is Awesome` { | |
override fun toString(): String { | |
return "welcome to the party" | |
} | |
} | |
fun main(args: Array<String>) { | |
val pizzaIsAwesome = `Pizza Is Awesome`() //new Pizza Is Awesome | |
println(pizzaIsAwesome::class.java) //class main.Pizza Is Awesome | |
val newInstance = pizzaIsAwesome::class.java.newInstance() | |
println(newInstance) //"welcome to the party" | |
} |
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
public class Main { | |
public static void main(String[] args) { | |
try { | |
Class classDefinition = Class.forName("main.Pizza Is Awesome"); | |
System.out.println(classDefinition); //class main.Pizza Is Awesome | |
System.out.println(classDefinition.newInstance()); //welcome to the party | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment