Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*******************************************************************
- // Java compiler created in PHP to quickly and safely test code.
- // NOTE: please read the 'More Info' tab to the right for shortcuts.
- //*******************************************************************
- import java.lang.Math; // header stuff MUST go above the first class
- // our main class becomes a file but the main method is still found
- public class HelloWorld
- {
- public static void main(String[] args)
- {
- OtherClass myObject = new OtherClass("Hello World!");
- System.out.print(myObject);
- new OtherClass.InnerStatic().innerMethod();
- System.out.print("" + OtherClass.InnerStatic.time);
- Dog dog = new Dog("hey");
- dog.change(dog);
- System.out.print(dog.name);
- }
- }
- // this will become its own file too (and these can be in any order)
- public class OtherClass
- {
- private String message;
- private boolean answer = false;
- public OtherClass(String input)
- {
- message = "Why, " + input + " Isn't this something?";
- }
- public String toString()
- {
- return message;
- }
- public static class InnerStatic{
- protected static String time = "time";
- public InnerStatic(){
- System.out.print("\nInnerStatic");
- }
- public static void innerMethod(){
- System.out.print("hey, I'm inner");
- //this.toString();
- };
- }
- }
- public class Dog
- {
- public String name;
- public Dog(String name){
- this.name = name;
- }
- public static void change(Dog dog){
- dog.name = "something else";
- }
- }
Add Comment
Please, Sign In to add comment