Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I klasi ipostiriksis:
- public class Rectangle
- {
- private int x,y;
- Rectangle()
- {
- x=2;
- y=4;
- }
- Rectangle(int par_x, int par_y)
- {
- x=par_x;
- y=par_y;
- }
- public int getEmvado()
- {
- return x*y;
- }
- }
- i main klasi:
- public class Askhsh
- {
- public static void main(String[] args)
- {
- Rectangle no1 = new Rectangle();
- Rectangle no2 = new Rectangle(3,5);
- System.out.println("To Emvado tou prwtou einai: " + no1.getEmvado());
- System.out.println("To Emvado tou deuterou einai: " + no2.getEmvado());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement