Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Circular list of Java programming     - How to install Gnome 3.10 in Ubuntu 13.10 (Linux)

- Linux system crash (no such file or directory) How to rescue database (Linux)

- Build your own CA services: OpenSSL command line CA Quick Guide (Server)

- Orabbix binding Python send graphical reports (Linux)

- Introduction and bash history command to quickly call (Linux)

- Basic data types JavaScript type system and the type of packaging (Programming)

- Ubuntu and derivative users to install the system launcher SimDock 1.3 (Linux)

- Use MongoDB C # MongoDB official driving operation (Database)

- Java method to read and write files summary (Programming)

- Linux installation beautify early experience (Linux)

- MySQL script incremental backups (innobackupex) (Database)

- Linux Getting Started tutorial: Borrow Windows fonts in Ubuntu 14.10 (Linux)

- Analysis: Little Notebook facing a major security threat secure online (Linux)

- How to achieve the MySQL Oracle table associated with the two operations update (Database)

- ARM Linux system call (Linux)

- Android timer use (Programming)

- The direct insertion sort algorithm (Programming)

- Linux Task Scheduler (at, crontab) (Linux)

- CentOS6.x and Windows XP and Windows Server 2003 Open IPv6 related matters (Linux)

- Ubuntu users to install Gnome-Pie 0.6.5 (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;
        }
    }
}
     
         
       
         
  More:      
 
- Sublime Text Add instructions to insert the current time zone (Linux)
- Java object serialization (Programming)
- Protobuf compiled and used on the Ubuntu 14.04 (Programming)
- Getting Started with Linux system to learn: how to check in a package is installed on Ubuntu (Linux)
- Depth understanding of the TCP protocol (Database)
- Use NTFS-3G to mount NTFS partitions under Linux U disk and removable hard disk (Linux)
- VSFTPD Security (Linux)
- Debian Stable (Jessie 8.1) of normal.mod not found (Linux)
- Nginx Performance Tuning Guidelines (Server)
- Spark SQL job of a lifetime (Server)
- Compare several ways to transfer files between Linux hosts (Linux)
- Configuring a Linux operating system against syn attack (Linux)
- Linux ldconfig command (Linux)
- CentOS install SVN server configuration and automatically synchronized to the Web directory (Server)
- OpenJDK 7 compiled under Ubuntu 14.04.3 64-bit (Linux)
- Several back door and log tool under Linux (Linux)
- A key installation Gitlab 7 on RHEL6.4 and Setup Mail TX (Linux)
- LinkedList Basic Usage (Programming)
- Under CentOS Linux automatic backup MySQL database daily (Database)
- C data types is how it is supported by most computer systems (Programming)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.