Q1: Use the setCharAt() method in StringBuilder class to edit a String "java". After editing it, the String will be "Java".
Q2: Write a Java program to define the ListNode in the LinkedList:
Ans
code:-
import java.util.*;
class MyClass {
public static void main(String[ ] args) {
StringBuilder s=new StringBuilder("java");
s.setCharAt(0,'J');//at index 0 replace
System.out.println(s);//print
}
}
Node head;
class Node{
int data;//data
Node link;//link to next
Node(int d){//initialise
data = d;
}
}
If any doubt ask in the comments.
Get Answers For Free
Most questions answered within 1 hours.