Dear All!!,
I have a problem on my java program. pls help me as i can't find error.
below is my java coding.
import java.io.*;
public class Demo {
static Node objLL;
static BufferedReader br = new BufferedReader (new
InputStreamReader ( System.in));
public static void main (String args[]) throws IOException {
int choice = 0;
do {
System.out.println ("\nDemo:");
System.out.println ("-----\n");
System.out.println ("Press (1) to ADD.");
System.out.println ("Press (2) to VIEW.");
System.out.println ("Press (3) to EXIT.");
System.out.print ("Choice: ");
choice = Integer.parseInt (br.readLine ());
if (choice == 1)
add ();
else if (choice == 2)
view ();
} while (choice != 3);
}
static void add () {
if (objLL == null)
objLL = new Node ();
else {
Node temp = objLL;
while (temp != null)
temp = temp.next;
temp = new Node ();
}
System.out.println ("\nNode added.");
}
static void view () {
if (objLL == null)
System.out.println ("\nNo nodes to display.");
else {
System.out.println ();
int loopCount = 0;
for (loopCount = 1; loopCount <=
objLL.nodeCount; loopCount++)
System.out.println (loopCount);
System.out.println ();
}
}
}
class Node {
public Node next;
static int nodeCount;
Node () {
next = null;
nodeCount++;
}
}
that is program process
when u run the program.............
1.add
2.view
3.exit
enter ur number - 1
enter ur username - aung aung
enter ur ID - 122333
enter ur contact number - 313412415
enter ur genter - m
enter ur number - 2
user name user ID contact number genter
----------------------------------------------------------------------------------------
aungaung 12333 313412415 m
enter ur number - 1
enter ur username - aye
enter ur ID - 22222
enter ur contact number - 22222222
enter ur genter - f
enter ur number - 2
user name user ID contact number genter
----------------------------------------------------------------------------------------
aungaung 12333 313412415 m
aye 22222 222222222 f
enter ur number - 3
program end .........
that is all the process
no need DB and no need array
only simple java code
thx 4 helping me .
Help Me, Pls
|