I get an error when im trying to run this java program, I wouldappreciate if someone helped me asap, I will make sure to leave agood review. thank you in advance!
java class Node
public class Node {
private char item;
private Node next;
Object getNext;
public Node(){
 Â
item = ' ';
next = null;
}
public Node(char newItem) {
setItem(newItem);
next = null;
}
public Node(char newItem, Node newNext){
setItem(newItem);
setNext(newNext);
}
public void setItem(char newItem){
item = newItem;
}
public void setNext(Node newNext){
next = newNext;
}
public char getItem(){
return item;
}
public Node getNext(){
return next;
}
 Â
}
java class LinkedString
public class LinkedString {
Node head;
int length;
 Â
public LinkedString(char[] characters) {
for(int i=0;iNode newNode = new Node(characters[i]);
if(head==null) {
head = newNode;
}
else
{
Node curr=head;
while(curr.getNext!=null)
{
curr=curr.getNext();
}
curr = newNode;
}
}
length=characters.length;
}
public LinkedString(String str) {
for(int i=0;iNode newNode = new Node(str.charAt(i));
if(head==null) {
head = newNode;
}
else
{
Node curr=head;
while(curr.getNext!=null)
{
curr=curr.getNext();
}
curr = newNode;
}
}
length=str.length();
}
 Â
public char charAt(int index)
{
Node curr;
curr = head;
if (index == 0){
return curr.getItem();
}else if(index > 0 && index < length){
for (int i = 1; icurr = curr.getNext();
}
}
return 0;
}
 Â
public LinkedString concat(LinkedString str)
{
if(isEmpty())
{
length=str.length();
return str;
}
Node curr=head;
while(curr.getNext!=null)
{
curr = curr.getNext();
}
curr.setNext(str.head);
length=length+str.length();
return this;
}
 Â
public boolean isEmpty() {
return length==0;
}
 Â
public int length() {
return length;
}
 Â
public LinkedString replace(char oldChar,char newChar) {
Node curr = head;
while(curr!=null) {
if(curr.getItem()==oldChar)
curr.setItem(newChar);
curr = curr.getNext();
}
 Â
return this;
}
 Â
public String toString() {
Node curr = head;
String ans = \"\";
while(curr!=null) {
ans+=curr.getItem();
curr = curr.getNext();
}
return ans;
} Â Â
}
java class test
public class Test {
public static void main(String[] args) {
char array[]= {'m','a','h','d','i'};
System.out.println(\"String 1: \");
LinkedString LS1=new LinkedString(array);
System.out.println(\"isEmpty: \"+LS1.isEmpty());
System.out.println(\"Length :\"+LS1.length());
System.out.println(\"String form: \"+LS1.toString());
System.out.println(\"Character At index 3: \"+LS1.charAt(3));
 Â
System.out.println(\"\nlinkedString Object 2: \");
LinkedString LS2=new LinkedString(\"mazloumi\");
System.out.println(\"isEmpty: \"+LS2.isEmpty());
System.out.println(\"Length :\"+LS2.length());
System.out.println(\"String form: \"+LS2.toString());
System.out.println(\"Character At index 5: \"+LS2.charAt(5));
 Â
 Â
System.out.println(\"\nConcatenated linked String: \");
LinkedString LS3=LS1.concat(LS2);
System.out.println(\"isEmpty: \"+LS3.isEmpty());
System.out.println(\"Length :\"+LS3.length());
System.out.println(\"String form: \"+LS3.toString());
System.out.println(\"Character At index 10: \"+LS3.charAt(10));
 Â
System.out.println(\"\nReplaced String: \");
LinkedString ls4=LS3.replace('a', 'o');
System.out.println(ls4.toString());
}
}