Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

********** Please Implement the following using JAVA ********* The String class is provided in the Java library. Provide your own implementation for the following methods

********** Please Implement the following using JAVA *********

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 DriverMain class...

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]); } } }

the MyString class referenced from DriverMain is as follows...

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(){ } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions

Question

List the nodes in decision trees.

Answered: 1 week ago

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago