-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.java
More file actions
65 lines (44 loc) · 1.07 KB
/
Stack.java
File metadata and controls
65 lines (44 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
public class Stack {
//2.1 Write code to remove duplicates from an unsorted linked list.
public Node init(char[] content, int length){
Node head = new Node();
Node temp = head;
for(int i=0; i<length; i++){
temp.setData(content[i]);
System.out.println(content[i]);
Node node = new Node();
temp.setNext(node);
temp = temp.getNext();
}
return head;
}
//print out the stack
public void printStack(Node head){
while(head.getNext() != null){
System.out.println(head.getData());
}
}
//print out the data on top
public void top(){
}
//insert a new data on the top
public void push(){
}
//delete the data on the top
public void pop(){
}
//public static
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Please enter your string:");
String in = input.nextLine();
int length = in.length();
char[] content = in.toCharArray();
input.close();
}
}