Java Recursive simple application tutorial

Source: Internet
Author: User

Package com.xiaohao.test;

Import java.util.ArrayList;
Import java.util.List;
Import Java.util.Locale;
Import Java.util.ResourceBundle;

public class Test {



/**
* |-Marketing Department
* |-Propaganda Department
* |-Business Department
* |-Business
* |-Business Department TWO
* |-Development Department
* |-Develop a
* |-Development of TWO
* @param args
*/



Public arraylist<department> init () {

Department depart_7=new Department ("Business part", NULL);
Department depart_8=new Department ("Business Two", NULL);

Department depart_5=new Department ("Development of a", null);
Department depart_6=new Department ("Development Two", NULL);

Arraylist<department> list=new arraylist<department> ();
List.add (depart_7);
List.add (Depart_8);
Department depart_4=new Department ("Business unit", list);
Department depart_3=new Department ("propaganda department", NULL);

Arraylist<department> list2=new arraylist<department> ();
List2.add (Depart_3);
List2.add (Depart_4);
Department depart_1=new Department ("marketing Department", List2);

Arraylist<department> list3=new arraylist<department> ();
List3.add (depart_5);
List3.add (Depart_6);
Department depart_2=new Department ("Development Department", LIST3);

Arraylist<department> list4=new arraylist<department> ();
List4.add (depart_1);
List4.add (depart_2);
Department depart_0=new Department ("root", list4);
Return (arraylist<department>) depart_0.getchildrendepartment ();
}

public void showdepartment (list<department> list,string prefix) {
if (list==null)
return;
prefix= Prefix+ "";
for (Department department:list)
{
System.out.println (prefix+ "|-" +department.getname ());
Showdepartment (department.getchildrendepartment (), prefix);
}


}

@org. Junit.test
public void Test () {
arraylist<department> list=init ();
S Howdepartment (List, "");
}

public static void Main (string[] args) {
locale[] locals=locale.getavailablelocales ();
System.out.println ("All languages supported by Java are as follows:");
System.out.println ("--------------------------------------------------------------------");
for (Locale local:locals)
{
System.out.println (local.getdisplaylanguage ());
}
System.out.println ("--------------------------------------------------------------------");

Locale Local=locale.getdefault ();
ResourceBundle resource=resourcebundle.getbundle ("Com.xiaohao.test.xiaohao", local);
System.out.println (resource.getstring ("UserName"));

}
}

Java Recursive simple application tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.