subject

The String class is provided in the Java library. Provide your own implementation for the following methods (name the new class MyString):

**DO NOT USE THE STRING OBJECT AND ITS METHODS. IMPLEMENT THEM ALL AGAIN YOURSELF!

**You can use char[] and Character object.

public MyString(char[] chars);

public char charAt(int index);

public int length();

public MyString substring(int begin, int end);

public MyString toLowerCase();

public boolean equals(MyString s);

public static MyString valueOf(int i);

public char[] toChars();

Use the following class driver with no modifications to it!

import java. util.*;
import java. lang.*;
import java. io.*;

class DriverMain{

public static void main(String[] args) {

MyString s1 = new MyString(new char[] {'A', 'B', 'C'});

System. out. println(s1.length());

System. out. println(s1.charAt(1));

MyString s2 = s1.substring(0,2);

System. out. println(s2.toLowerCase().equals(new MyString(new char[] {'a', 'b'})));

char[] chars = MyString. valueOf(345).toChars();

for (int i = 0; i < chars. length; i++) {

System. out. print(chars[i]);

}

}

}



---And use the following class that was refered to in main

class MyString {

public MyString(char[] chars){

}
public char charAt(int index){

}
public int length(){

}
public MyString substring(int begin, int end){

}
public MyString toLowerCase(){

}
public boolean equals(MyString s){

}
public static MyString valueOf(int i){

}
public char[] toChars(){

}

}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:00
Which requirement is an appropriate reason for a business to use it tools
Answers: 3
question
Computers and Technology, 22.06.2019 19:40
Solve the following javafx application: write a javafx application that analyzes a word. the user would type the word in a text field, and the application provides three buttons for the following: - one button, when clicked, displays the length of the word.- another button, when clicked, displays the number of vowels in the word.- another button, when clicked, displays the number of uppercase letters in the word(use the gridpane or hbox and vbox to organize the gui controls).
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
Answers: 1
You know the right answer?
The String class is provided in the Java library. Provide your own implementation for the following...
Questions
question
History, 23.02.2021 02:00
question
English, 23.02.2021 02:00
Questions on the website: 13722359