🔒 Closed Object as parameter

Status
Not open for further replies.

meta29

Enthusiast
Ngayon ko lang din nalaman na 😅pwedi palang gawing parameter ang isang object.
mahirap talaga pag sariling sikap lang maraming nakakaligtaan.

Code:
class Id{

  private String name;
 
 
  Id(String name){
   this.name = name;
  }
 
 
  void check (Id person){
    
    if(person.name.startsWith("J")){
    
      System.out.println("Mr "+person.name);
      System.out.println("my discount ka! dahil nagsisimula");
      System.out.println("sa letrang J ang pangalan mo\n");
      
    }else{
      System.out.print("Sorry "+person.name);
      System.out.println("\twala kang discount");
    }
  }
 
}

public class Person {

  public static void main(String[] args) {
  
   Id person1 = new Id("John");
   Id person2 = new Id("Meta");
  
   person1.check(person1);
   person2.check(person2);
  
 
 
 
 
  }

}

nshot_20200421_004210_com.duy.compiler.javanide.md.webp

kung alam mo na😅Salamat sa pagbabasa.
 
Classes considered as data type.

Data Types in Java
Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java:

  1. Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double.
  2. Non-primitive data types: The non-primitive data types include You do not have permission to view the full content of this post. Log in or register now., You do not have permission to view the full content of this post. Log in or register now., and You do not have permission to view the full content of this post. Log in or register now..
You do not have permission to view the full content of this post. Log in or register now.
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 340
    Views
  • 4
    Participants
Last reply from:
Carly_Rose

Online now

Members online
1,035
Guests online
725
Total visitors
1,760

Forum statistics

Threads
2,276,975
Posts
28,973,480
Members
1,229,674
Latest member
Mjivo
Back
Top