Snippets

Ettar Java Copy

Created by Ettar last modified
public class TestObject {

    private int testInt;
    private String testString;
    
    public TestObject(int testInt,String testString){
        setTestInt(testInt);
        setTestString(testString);
    }

    public TestObject(TestObject other){
        setTestString(other.getTestString());
        setTestInt(other.getTestInt());
    }

    public int getTestInt() {
        return testInt;
    }

    public String getTestString() {
        return testString;
    }

    public void setTestInt(int testInt) {
        this.testInt = testInt;
    }

    public void setTestString(String testString) {
        this.testString = testString;
    }
}
1
2
3
4
5
6
7
8
9
public class mainClass {
    public static void main(String[] ARGS){
        TestObject t1=new TestObject(1,"abc");
        TestObject tk = new TestObject(t1.getTestInt(),t1.getTestString());
        TestObject ntk = t1;
        TestObject tk2 = new TestObject(t1);
        System.out.println();
    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.