Skip to content

Instantly share code, notes, and snippets.

@joshskeen
Created August 4, 2017 14:54
Show Gist options
  • Save joshskeen/ed3f87426bf0588c47c9224143ebdfac to your computer and use it in GitHub Desktop.
Save joshskeen/ed3f87426bf0588c47c9224143ebdfac to your computer and use it in GitHub Desktop.
horrid names in kotlin <--> java
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"
}
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