Question

Q1: Use the setCharAt() method in StringBuilder class to edit a String "java". After editing it,...

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:

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please code in Java Write a recursive method that takes a string and return a string...
Please code in Java Write a recursive method that takes a string and return a string where every character appears twice. For example, if the string is “HELLO”, it will return “HHEELLOO”. Write a program to test it.
write a program (in Java/Eclipse to loop through a string character by character. If the character...
write a program (in Java/Eclipse to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.) String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n";
2- Given following data structures of a double linked list :    class ListNode      {...
2- Given following data structures of a double linked list :    class ListNode      {         String info ;         ListNode prev ;        ListNode next ;           …….      }    Write a Java method which prints the content of double linked list in reverse order.
) IN JAVA: Write a recursive method lowestPaidEmployeeRec that is placed in the linked list after...
) IN JAVA: Write a recursive method lowestPaidEmployeeRec that is placed in the linked list after the method countHighEarners. Method returns employee with lowest salary in entire linked lists of employees. Assume the same LinkedList class as is given as in question 10 above. // PRECONDITION: Linked list is not empty. public Employee lowestPaidEmployeeRec(Node first) // first is reference to the beginning of linked list. { }
JAVA: Write a method with the following header to return a string format to represent the...
JAVA: Write a method with the following header to return a string format to represent the reverse order of the integer: public static String reverse(int number) For example, reverse(3456) returns 6543 and reverse(809340) returns 043908. Write a test program that prompts the user to enter an integer then displays its reversal. Convert integer to string and print reverse of integer as string. Do not use built-in toString. Use loop.
(Java) Write the missing equals method needed for the Point class shown on the screen to...
(Java) Write the missing equals method needed for the Point class shown on the screen to work with this program. The missing method would be added to the Point class. class PointTestP3 {   public static void main(String[] args) {    Point p1 = new Point(5, 6);     Point p2 = new Point(5, 6);        System.out.println(p1.equals(p2)); // prints "true"   } }
Java programming. Write a public Java class called WriteToFile that opens a file called words.dat which...
Java programming. Write a public Java class called WriteToFile that opens a file called words.dat which is empty. Your program should read a String array called words and write each word onto a new line in the file. Your method should include an appropriate throws clause and should be defined within a class called TextFileEditor. The string should contain the following words: {“the”, “quick”, “brown”, “fox”}
Write a Java program with a method public String replaceChar(String p, int k, char c) {...
Write a Java program with a method public String replaceChar(String p, int k, char c) { } that given a String p, an int k, and a char c, returns a String with the kth character replaced by c. Of course, 0<=k<=p.length()-1, otherwise raise an exception or error.
What is the output of the following Java program? class Food { String flavor = "bland";...
What is the output of the following Java program? class Food { String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; Pepper(String flavor) { this.flavor = flavor; } } public class Lunch { public static void main(String[] args) { Pepper pepper = new Pepper("sweet"); System.out.println(pepper.flavor); } } Select one: a. bland b. the program does not compile c. no output d. spicy e. sweet
Write Java program Lab51.java which takes in a string from the user, converts it to an...
Write Java program Lab51.java which takes in a string from the user, converts it to an array of characters (char[] word) and calls the method: public static int countVowels(char[]) which returns the number of vowels in word. (You have to write countVowels(char[]) ).
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT