Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.peter.car;
- import com.peter.parts.Color; // importing from package from com.peter.parts
- public class Main {
- public static void main(String[] args) {
- String paint = "Red Color";
- Color ObColor = new Color(paint); // Constructor
- System.out.println(ObColor.getColor());
- System.out.println(ObColor.paint1);
- }
- }
- --------------------------------------------->
- package com.peter.parts;
- public class Color {
- private String paint;
- public String paint1 = "Orange Color";
- public Color(String paint){ // Constructor
- this.paint = paint;
- }
- public String getColor(){
- return paint;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment