Click here to Skip to main content
15,886,689 members
Home / Discussions / Java
   

Java

 
Questionjava Pin
Member 1343015225-Sep-17 22:16
Member 1343015225-Sep-17 22:16 
AnswerRe: java Pin
jschell27-Sep-17 9:26
jschell27-Sep-17 9:26 
QuestionWav file problems Pin
Member 1340872613-Sep-17 14:21
Member 1340872613-Sep-17 14:21 
AnswerRe: Wav file problems Pin
Richard MacCutchan13-Sep-17 19:11
mveRichard MacCutchan13-Sep-17 19:11 
AnswerRe: Wav file problems Pin
jschell26-Sep-17 8:18
jschell26-Sep-17 8:18 
QuestionHello India 123 Pin
daves312-Sep-17 4:55
daves312-Sep-17 4:55 
AnswerRe: Hello India 123 Pin
jschell12-Sep-17 6:09
jschell12-Sep-17 6:09 
QuestionSingly Linked List Pin
kinderu12-Sep-17 2:58
kinderu12-Sep-17 2:58 
Hello!
In the next code, I've made a singly linked list.
In the AddNODE line(obj1) I called the AddNODE function, function which receives as parameter an object obj1 of type NODE.
The problem is the AddNODE(NODE newNode) function.
This newNODE must be an object or I think it would be like this.
Can you help me ?

Java
class Persons
{
    public String firstName;
    public String secondName;
    public String CNP;
    public String Email;

};

class NODE
{
    private NODE next;
    public Persons box = new Persons();
    public NODE(String firstName, String secondName, String CNP, String Email)
    {
        box.firstName = firstName;
        box.secondName = secondName;
        box.CNP = CNP;
        box.Email = Email;
    }
    public NODE GetNext()
    {
        return next;
    }
    public void SetNext(NODE next)
    {
        this.next = next;
    }
};

class SinglyLinkedList
{
    private NODE head;
    public SinglyLinkedList()
    {
        head = null;
    }
    public boolean isEmpty()
    {
        return head == null;
    }
    public void AddNODE(NODE newNode)
    {
        NODE temp = null;
        if (isEmpty())
            head = temp = newNode;
        else
        {
            temp.SetNext(newNode);
            temp = newNode;
        }
        temp.SetNext(null);
    }
    public void Print()
    {
        NODE temp = head;
        while (temp != null)
        {
            System.out.print("\n First Name   : " + temp.box.firstName);
            System.out.print("\n Second Name  : " + temp.box.secondName);
            System.out.print("\n CNP          : " + temp.box.CNP);
            System.out.print("\n Email        : " + temp.box.Email);
            temp = temp.GetNext();
            System.out.print("\n");
        }
    }
};

public class MyClass
{
    public static void main(String args[])
    {
        SinglyLinkedList ptr = new SinglyLinkedList();

        NODE obj1 = new NODE("Dragu", "Stelian", "1811226284570", "dragu_stelian@yahoo.com");
        NODE obj2 = new NODE("Popescu", "Mircea", "1891226284462", "popescu.mircea@yahoo.com");
        
        ptr.AddNODE(obj1);
        ptr.AddNODE(obj2);

        ptr.Print();
    }
}

AnswerRe: Singly Linked List Pin
Richard MacCutchan12-Sep-17 5:07
mveRichard MacCutchan12-Sep-17 5:07 
GeneralRe: Singly Linked List Pin
kinderu12-Sep-17 5:13
kinderu12-Sep-17 5:13 
GeneralRe: Singly Linked List Pin
Richard MacCutchan12-Sep-17 5:37
mveRichard MacCutchan12-Sep-17 5:37 
GeneralRe: Singly Linked List Pin
Richard Deeming12-Sep-17 6:12
mveRichard Deeming12-Sep-17 6:12 
Questionfinger print Pin
Member 1314044319-Aug-17 1:45
Member 1314044319-Aug-17 1:45 
AnswerRe: finger print Pin
jschell21-Aug-17 5:43
jschell21-Aug-17 5:43 
AnswerRe: finger print Pin
Patrice T25-Aug-17 19:26
mvePatrice T25-Aug-17 19:26 
Generaljava Pin
Member 1336471716-Aug-17 19:34
Member 1336471716-Aug-17 19:34 
GeneralRe: java Pin
Richard MacCutchan16-Aug-17 21:17
mveRichard MacCutchan16-Aug-17 21:17 
GeneralRe: java Pin
Patrice T23-Aug-17 16:19
mvePatrice T23-Aug-17 16:19 
QuestionHow to Connect Fingerprint Reader To Java Program Pin
Kistlak12-Aug-17 10:34
Kistlak12-Aug-17 10:34 
AnswerRe: How to Connect Fingerprint Reader To Java Program Pin
Richard MacCutchan12-Aug-17 20:50
mveRichard MacCutchan12-Aug-17 20:50 
SuggestionRe: How to Connect Fingerprint Reader To Java Program Pin
Richard Deeming13-Aug-17 23:42
mveRichard Deeming13-Aug-17 23:42 
GeneralRe: How to Connect Fingerprint Reader To Java Program Pin
Kistlak14-Aug-17 21:28
Kistlak14-Aug-17 21:28 
QuestionReplace placeholders with HTML text in dotx file using docx4 Pin
Sandeep Reddy9-Aug-17 0:08
Sandeep Reddy9-Aug-17 0:08 
AnswerRe: Replace placeholders with HTML text in dotx file using docx4 Pin
jschell14-Aug-17 8:25
jschell14-Aug-17 8:25 
QuestionConvert ms word to PDF on linux Pin
Member 128526088-Aug-17 0:47
Member 128526088-Aug-17 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.