ч? public class Main { } 2. Number = -10 1. Number = 0 public int number; public void assignIfPositive(int a) { } if(a > 0) number = a; System.out.println("a is positive"); ٘ח ܲ ࢎۈҗ ࢎࣗా ೞח ߣ૩ ࣻױ. 2. Number = -10
doProcessRandomly() { double n = Math.random(); if (n > 10) { System.out.println("n is over 10"); } else { System.out.println("n is " + n); } } 2. N is over 10 1. N is 0.15.. 3. Random ل ೞա 1. N is 0.15.. ▸ Math.random() ೣࣻח 0җ 1ࢎ чਸ ߈ജೠ. // if ղ ٘ח प೯ ؼ ࣻ হח લ ٘. double n = GdgUtils.getRandomValue(); ▸ ழझథ ೣࣻо ٜযрݶ? ࠛਃೠ ٘ח ਕ
static void main(String[] args) { PetFeeder feeder = new PetFeeder(); Dog lassie = new Dog(); feeder.giveFood(lassie); class Cat { public void feed() { System.out.println("cat feed"); } } class PetFeeder { public void giveFood(Dog d) { d.feed(); } class Dog { public void feed() { System.out.println("dog feed"); } } য ېझ } Cat felix = new Cat(); feeder.giveFood(felix); giveFood(felix); } public void giveFood(Cat c) { c.feed(); }
static void main(String[] args) { PetFeeder feeder = new PetFeeder(); Dog lassie = new Dog(); feeder.giveFood(lassie); class Cat { public void feed() { System.out.println("cat feed"); } } class PetFeeder { public void giveFood(Dog d) { d.feed(); } public void giveFood(Cat c) { c.feed(); } } class Dog { public void feed() { System.out.println("dog feed"); } } য ېझ } Cat felix = new Cat(); feeder.giveFood(felix); giveFood(felix); interface Pet { void feed(); } class PetFeeder { public void giveFood(Pet p) { p.feed(); } } implements Pet { implements Pet { ёೱ ۽Ӓې߁ ࢸ҅ח ੋఠಕझ ۽Ӓې߁ਸ ࢶഐೠ.