JAVA
java
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
class Node {
Node next;
int data;
Node(int x) {
data = x;
next = null;
}
}
public class insertBegin {
static Node insertStart(Node head, int x) {
Node temp = new Node(x);
temp.next = head;
return head;
}
public static void main(String[] args) {
Node head = null;
head = insertStart(head, 23);
head = insertStart(head, 30);
head = insertStart(head, 50);
System.out.println(head.data);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run