SHARE
TWEET

Overriding

luqman0611 Feb 21st, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. public class main {
  4.     public static void main(String[] args) {
  5.         // write your code here
  6.         NameCard nameCard = new NameCard();
  7.         nameCard.nama("Husna");
  8.  
  9.         nameCard.nama("Huda","kedungmiri");
  10.  
  11.         nameCard.nama("hamdan","kedungmiri",70);
  12.     }
  13. }
  14.  
  15. package com.company;
  16.  
  17. public class NameCard {
  18.     String nama(String nama){
  19.         System.out.println("=================================");
  20.         System.out.println(nama);
  21.  
  22.         return nama;
  23.     }
  24.  
  25.     String nama(String nama, String alamat){
  26.         System.out.println("=================================");
  27.             System.out.println(nama);
  28.             System.out.println(alamat);
  29.  
  30.         return nama;
  31.     }
  32.  
  33.     String nama(String nama, String alamat, int nomor){
  34.  
  35.         System.out.println("=================================");
  36.         System.out.println(nama);
  37.         System.out.println(alamat);
  38.         System.out.println(nomor);
  39.  
  40.         return nama;
  41.     }
  42. }
  43.  
  44.  
  45. =========
  46. kemapuan dalam membuat nama method yang sama tapi beda para meter
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top