- public class CertificateDemo1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Certificate1 certificate1= new Certificate1(60,"cnexirk","cbnifms",77);
- Certificate1 certificate2= new Certificate1(45,"gphspvq","pqjbhmz",62);
- Certificate1 certificate3= new Certificate1(41,"nfpxsmp","vimiopu",89);
- Certificate1 certificate4= new Certificate1(95,"ionouca","bsbknpx",38);
- Certificate1 certificate5= new Certificate1(39,"yhzrafu","itnbskb",44);
- Certificate1[] objArray= {certificate1,certificate2,certificate3,certificate4,certificate5};
- Certificate1[] objResultArray1= getEvenPositionCertificate(objArray);
- if(objResultArray1==null){
- System.out.println("Output after first operation is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(Certificate1 certificate:objResultArray1){
- System.out.println(certificate.getId()+" " + certificate.getTitle()+" " + certificate.getDate()+" " + certificate.getRank()+" ");
- }
- }
- }
- public static Certificate1[] getEvenPositionCertificate(Certificate1[] obj)
- {
- int n=((obj.length)/2)+1;
- Certificate1[] obj1=new Certificate1[n];
- int j=0;
- for(int i=0; i<obj.length; i++)
- {
- if(i%2==0)
- {
- obj1[j]=obj[i];
- j++;
- }
- }
- return obj1;
- }
- }
- class Certificate1
- {
- private int id,rank;
- private String title,date;
- public Certificate1(int id,String title,String date,int rank)
- {this.id=id;
- this.title=title;
- this.date=date;
- this.rank=rank;
- }
- int getId()
- {
- return id;
- }
- int getRank()
- {
- return rank;
- }
- String getTitle()
- {
- return title;
- }
- String getDate()
- {
- return date;
- }
- void setId(int id)
- {
- this.id=id;
- }
- void setRank(int rank) {
- this.rank = rank;
- }
- void setTitle(String title) {
- this.title = title;
- }
- void setDate(String date) {
- this.date = date;
- }
- }
- .......................................................................................................................................................................
- public class CertificateDemo1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Certificate1 certificate1= new Certificate1(60,"cnexirk","cbnifms",77);
- Certificate1 certificate2= new Certificate1(45,"gphspvq","pqjbhmz",62);
- Certificate1 certificate3= new Certificate1(41,"nfpxsmp","vimiopu",89);
- Certificate1 certificate4= new Certificate1(95,"ionouca","bsbknpx",38);
- Certificate1 certificate5= new Certificate1(39,"yhzrafu","itnbskb",30);
- Certificate1[] objArray= {certificate1,certificate2,certificate3,certificate4,certificate5};
- Certificate1[] objResultArray1= searchCertificateByRank(objArray,44);
- if(objResultArray1.length==0){
- System.out.println("Output after first operation is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(Certificate1 certificate:objResultArray1){
- System.out.println(certificate.getId()+" " + certificate.getTitle()+" " + certificate.getDate()+" " + certificate.getRank()+" ");
- }
- }
- }
- public static Certificate1[] searchCertificateByRank (Certificate1[] obj,int rank)
- {
- int j=0;
- int c=0;
- for(int i=0; i<obj.length; i++)
- {
- int no=obj[i].getRank();
- if(no==rank) {
- c++;
- }
- }
- Certificate1 [] arr=new Certificate1[c];
- for(int i=0; i<obj.length; i++)
- {
- int no=obj[i].getRank();
- if(no==rank)
- {
- arr[j]=obj[i];
- j++;
- }
- }
- return arr;
- }
- }
- class Certificate1
- {
- private int id,rank;
- private String title,date;
- public Certificate1(int id,String title,String date,int rank)
- {this.id=id;
- this.title=title;
- this.date=date;
- this.rank=rank;
- }
- int getId()
- {
- return id;
- }
- int getRank()
- {
- return rank;
- }
- String getTitle()
- {
- return title;
- }
- String getDate()
- {
- return date;
- }
- void setId(int id)
- {
- this.id=id;
- }
- void setRank(int rank) {
- this.rank = rank;
- }
- void setTitle(String title) {
- this.title = title;
- }
- void setDate(String date) {
- this.date = date;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(22,"rsqhpiz","yjsympz");
- MailBox mailbox2= new MailBox(83,"xwjrqnu","ahrxtbb");
- MailBox mailbox3= new MailBox(47,"zgesjsr","cxnkctl");
- MailBox mailbox4= new MailBox(66,"xaosles","jvdrtxf");
- MailBox mailbox5= new MailBox(1,"yilxuua","ycnejof");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- MailBox mailboxRes1= new MailBox(27,"ffatwgo","dkxgaid");
- boolean result= replaceMailBoxById(objArray, mailboxRes1);
- System.out.println("Output for performing replace on mailboxRes1 is: "+ result );
- System.out.println("Displaying contents of array: ");
- for(MailBox mailbox:objArray){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- System.out.println();
- MailBox mailboxRes2= new MailBox(1,"hqzmrfz","fcbudyi");
- result= replaceMailBoxById(objArray, mailboxRes2);
- System.out.println("Output for performing replace on mailboxRes2 is: "+ result );
- System.out.println("Displaying contents of array: ");
- for(MailBox mailbox11:objArray){
- System.out.println(mailbox11.getId()+" " + mailbox11.getName()+" " + mailbox11.getCreationDate()+" ");
- }
- }
- public static boolean replaceMailBoxById(MailBox[] objArry,MailBox objNew)
- {
- for(int i=0; i<objArry.length; i++)
- {
- if(objArry[i].getId()==objNew.getId())
- {
- objArry[i]=objNew;
- return true;
- }
- }
- return false;
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(22,"rsqhpiz","yjsympz");
- MailBox mailbox2= new MailBox(83,"xwjrqnu","ahrxtbb");
- MailBox mailbox3= new MailBox(47,"zgesjsr","cxnkctl");
- MailBox mailbox4= new MailBox(66,"xaosles","jvdrtxf");
- MailBox mailbox5= new MailBox(1,"yilxuua","ycnejof");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- sortMailBoxById(objArray);
- System.out.println("Displaying contents of array: ");
- for(MailBox mailbox:objArray){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- public static void sortMailBoxById(MailBox[] objArry)
- {
- for(int i=0; i<objArry.length; i++)
- {
- for(int j=i+1; j<objArry.length; j++)
- if(objArry[i].getId()>objArry[j].getId())
- {
- MailBox temp=objArry[i];
- objArry[i]=objArry[j];
- objArry[j]=temp;
- }
- }
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(67,"isyvzun","egyyxwz");
- MailBox mailbox2= new MailBox(74,"xrxpxrr","bkmxnck");
- MailBox mailbox3= new MailBox(12,"xcromhc","sbndhax");
- MailBox mailbox4= new MailBox(22,"jlnyloj","ouyrjyo");
- MailBox mailbox5= new MailBox(9,"xyyhkuk","usqzuhu");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- sortMailBoxByName(objArray);
- System.out.println("Displaying contents of array: ");
- for(MailBox mailbox:objArray){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- public static void sortMailBoxByName(MailBox[] objArry)
- {
- for(int i=0; i<objArry.length; i++)
- {
- for(int j=i+1; j<objArry.length; j++)
- if(objArry[i].getName().compareTo(objArry[j].getName())>0)
- {
- MailBox temp=objArry[i];
- objArry[i]=objArry[j];
- objArry[j]=temp;
- }
- }
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(66,"xiibrnp","twqjgvl");
- MailBox mailbox2= new MailBox(94,"wdgxzwr","pvixict");
- MailBox mailbox3= new MailBox(40,"xhetnxe","wvtmcwk");
- MailBox mailbox4= new MailBox(69,"abeshrf","mfdjwqq");
- MailBox mailbox5= new MailBox(92,"bhdeebj","oymobpe");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- sortMailBoxByCreationDate(objArray);
- System.out.println("Displaying contents of array: ");
- for(MailBox mailbox:objArray){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- public static void sortMailBoxByCreationDate(MailBox[] objArry)
- {
- for(int i=0; i<objArry.length; i++)
- {
- for(int j=i+1; j<objArry.length; j++)
- if(objArry[i].getCreationDate().compareTo(objArry[j].getCreationDate())>0)
- {
- MailBox temp=objArry[i];
- objArry[i]=objArry[j];
- objArry[j]=temp;
- }
- }
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(30,"lsatkwk","ckbkape");
- MailBox mailbox2= new MailBox(38,"jbqeszs","tzxuuhz");
- MailBox mailbox3= new MailBox(22,"rpatwey","qkkjexb");
- MailBox mailbox4= new MailBox(80,"pfciraa","unafxwg");
- MailBox mailbox5= new MailBox(39,"ghohpje","fglxdpa");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- MailBox[] objResultArray1= searchMailBoxByName(objArray, "hxrkvyu");
- if(objResultArray1==null){
- System.out.println("Output after first search is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray1){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- MailBox[] objResultArray2= searchMailBoxByName(objArray, "lsatkwk");
- if(objResultArray2==null){
- System.out.println("Output after first search is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray2){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- }
- public static MailBox[] searchMailBoxByName(MailBox[] objArry,String name)
- {
- int c=0;
- for(int i=0; i<objArry.length; i++)
- {
- String nam=objArry[i].getName();
- if(nam.equals(name))
- {c++;
- }
- }
- int j=0;
- MailBox[] arr= new MailBox[c];
- for(int i=0; i<objArry.length; i++)
- {
- String nam=objArry[i].getName();
- if(nam.equals(name))
- {
- arr[j]=objArry[i];
- j++;
- }
- }
- return arr;
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(93,"hfyquem","xclzutr");
- MailBox mailbox2= new MailBox(25,"ajdlukm","hzeustv");
- MailBox mailbox3= new MailBox(26,"rsusdgf","upxpgwq");
- MailBox mailbox4= new MailBox(37,"kasysrr","rahcqck");
- MailBox mailbox5= new MailBox(39,"fvhepzs","djkljsd");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- MailBox[] objResultArray1= searchMailBoxByCreationDate(objArray, "jvxfaua");
- if(objResultArray1==null){
- System.out.println("Output after first search is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray1){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- MailBox[] objResultArray2= searchMailBoxByCreationDate(objArray, "rahcqck");
- if(objResultArray2==null){
- System.out.println("Output after first search is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray2){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- }
- public static MailBox[] searchMailBoxByCreationDate(MailBox[] objArry,String name)
- {
- int c=0;
- for(int i=0; i<objArry.length; i++)
- {
- String nam=objArry[i].getCreationDate();
- if(nam.equals(name))
- {c++;
- }
- }
- int j=0;
- MailBox[] arr= new MailBox[c];
- for(int i=0; i<objArry.length; i++)
- {
- String nam=objArry[i].getCreationDate();
- if(nam.equals(name))
- {
- arr[j]=objArry[i];
- j++;
- }
- }
- return arr;
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(18,"scfkfwm","vjlhejv");
- MailBox mailbox2= new MailBox(44,"vykwuqm","hxbgccj");
- MailBox mailbox3= new MailBox(77,"ddwhwhg","eiqshsv");
- MailBox mailbox4= new MailBox(79,"ctppqch","quyvfim");
- MailBox mailbox5= new MailBox(9,"fdoyxqc","vikysdr");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- MailBox[] objResultArray1= getOddPositionMailBox(objArray);
- if(objResultArray1==null){
- System.out.println("Output after first operation is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray1){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- }
- public static MailBox[] getOddPositionMailBox(MailBox[] objArry)
- {
- int j=0;
- int c=(objArry.length/2);
- MailBox[] arr= new MailBox[c];
- for(int i=0; i<objArry.length; i++)
- {
- if(i%2!=0)
- {
- arr[j]=objArry[i];
- j++;
- }
- }
- return arr;
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
- public class MailBoxDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- MailBox mailbox1= new MailBox(7,"vjcmlwe","szfolwb");
- MailBox mailbox2= new MailBox(67,"imcftaw","jlnzywo");
- MailBox mailbox3= new MailBox(26,"lsckexs","lyqonys");
- MailBox mailbox4= new MailBox(5,"cbajxhj","rgwyxze");
- MailBox mailbox5= new MailBox(4,"bxifplc","wevsaco");
- MailBox[] objArray= {mailbox1,mailbox2,mailbox3,mailbox4,mailbox5};
- MailBox[] objResultArray1= getEvenPositionMailBox(objArray);
- if(objResultArray1==null){
- System.out.println("Output after first operation is null. ");
- }else{
- System.out.println("Displaying contents of result array: ");
- for(MailBox mailbox:objResultArray1){
- System.out.println(mailbox.getId()+" " + mailbox.getName()+" " + mailbox.getCreationDate()+" ");
- }
- }
- }
- public static MailBox[] getEvenPositionMailBox(MailBox[] objArry)
- {
- int j=0;
- int c=(objArry.length/2)+1;
- MailBox[] arr= new MailBox[c];
- for(int i=0; i<objArry.length; i++)
- {
- if(i%2==0)
- {
- arr[j]=objArry[i];
- j++;
- }
- }
- return arr;
- }
- }
- class MailBox
- {
- private int id;
- private String name,creationDate;
- public MailBox(int id, String name, String creationDate) {
- super();
- this.id = id;
- this.name = name;
- this.creationDate = creationDate;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- }
- .......................................................................................................................................................................
[text] eee
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: