Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

how can I make Locale output that the language of the passport is Russian, and for each element in the array list, to call the method isRussian();

public class Passport implements Comparable<Passport>{ 

    private  String firstName;
    private  String lastName;
    private Locale passportIssue;


// c-tor
public Passport(String firstName, String lastName, Locale passportIssue){ 

      this.firstName = firstName;
      this.lastName = lastName;
      this.passportIssue = passportIssue;

} 

//method
public boolean isRussian() { 

        If(passportIssue== "ru"){
                 return true;
           }
               return false;
    }

}


What I have tried:

List<Passport> pass= new ArrayList<>();Locale a= new Locale("ru");        

Passport p = new Passport("Erika",Ivanovich",new Locale("ru")); 

Passport p1 = new Passport ("Kemal", "Remzi", Locale.ENGLISH)


Passport p2 = new Passport ("Ivana",Bogdan",new Locale("ru"));

pass.add(p);
pass.add(p1);
pass.add(p2);

   System.out.println("Is the passport " + p.getPassIssue() + " russian? "
Posted
Updated 15-Dec-21 22:15pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900