classes and objects

 class pen{


    int tip;
    String color;

    void setTip(int Newtip){

        tip=Newtip;
    }

    void setColor(String newColor){

        color=newColor;

    }

}
public class oopj {
    public static void main(String[] args){

        pen p=new pen();

        p.color="green";
        // p.setColor("pink");
        p.setTip(24);

        System.out.println(p.color);




    }

}

Comments

Popular posts from this blog

Convert first letter to capital letter in java

Stair case traversal search

Palindrome of string my logic