Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Circular list of Java programming     - 10 practical Java programming technology (Programming)

- Confrontation dragged Library - Web front-end encryption slow (Linux)

- Generated characters using Java Videos (Programming)

- CentOS6.5 installation Docker (Linux)

- After installation of Debian 6.0 do a few things first (Linux)

- Two classic macro definition under Linux (Linux)

- Linux virtual machine settings network, hostname ssh access (Linux)

- Ubuntu cut screen method (Linux)

- Installation Android IDE development tools, Android Studio 1.5 under Ubuntu (Linux)

- OGG-03510 Problem (Database)

- The best tools and techniques to find data on a Unix system (Linux)

- Make command Detailed Tutorial (Programming)

- Sublime Text 3 best features, plug-ins and settings (Linux)

- To upgrade combat MongoDB database replication sets and split versions (Database)

- Notebook computer forget password solution (Linux)

- How VMware extend disk without rebooting the system (Linux)

- Linux system on how to use rsync to synchronize data (Server)

- Spring MVC Exception Handling (Programming)

- OpenSUSE / Linux network configuration (Linux)

- Why everybody ought to know LLVM (Linux)

  Circular list of Java programming
  Add Date : 2018-11-21      
  Circular linked list, like the name suggests cycle, so to build a linear table after, after the tail pointer .next = first like, as usual, to build a structure (similar to the C language structure, Java classes inside):

class Person {
    protected Person next;
    protected int data;
    public Person (int data) {
        this.data = data;
    public void display () {
        System.out.println (data);
/ *
* Next is a reference to the class after Person has not allocated on the heap of memory (here I'm not sure, guess the code)
* /

Then we have to write this list Person object class memory space, similar to writing a list of tools:

First, it must be to establish a head pointer to the first node:

protected Person first;

This first class without a reference when using this first object reference, must pay attention to the object of the agreement, under plus a constructor:

public link () {
        this.first = null;

The first node creation Well, when this object reference tools, the head node is defined, so write following a method used to create circular list:

public void fun () {
        Scanner s = new Scanner (System.in);
        System.out.print ( "Please enter the length of the list, enter the pure numbers:");
        int value = Integer.parseInt (s.nextLine ());
        Person p = null;
        first = new Person (n--); // must be a head node of the first to be established, since the beginning of the definition is the first
        p = first;
        while (n -> 0) {
            p.next = new Person (n + 1);
            p = p.next;
        p.next = first;

This class name link, see the constructor, the tools of the list is complete.

The following piece of code to write a reference to it, the code is very simple:

public class Huan {

    public static void main (String [] args) {
        // TODO Auto-generated method stub
        link l = new link ();
        l.fun ();
        Person p = l.first;
        while (p! = null) {
            p.display ();
            p = p.next;
- CentOS7 management of systemd (Linux)
- Android timer use (Programming)
- How to test your MongoDB application upgrade? (Database)
- cp: omitting directory error solutions under Linux (Linux)
- Static member variable modified (Programming)
- WordPress blog installation Redis Cache (Server)
- About Linux operating system security (Linux)
- Differences Shell scripting languages and compiled languages (Programming)
- Linux, grep, sed usage (Linux)
- MySQL migration tool used in the production environment (Database)
- Django url () function Detailed (Programming)
- JavaScript Advanced Programming notes event capture and event bubbling (Programming)
- The temporary operation of the document mkstemp on Linux (Linux)
- Tecplot Installation under Linux (Linux)
- CentOS Nginx achieve 3 virtual machine load balancing (Server)
- How to install PlayOnLinux 4.2.5 under Ubuntu 14.04 / 12.04 (Linux)
- Git remote repository Explanation (Linux)
- Method under Linux GCC Compiler shared library function export control (Programming)
- Linux system package manager (rpm, yum, source packages installation) (Linux)
- Oracle 11g forget approach SYS and SYSTEM password (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.