Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will implement your own version of the String class in Java, named MyString. The class will have just one public attribute

In this assignment you will implement your own version of the String class in Java, named MyString. The class will have just one public attribute charArray of type character array

image text in transcribed

The class will have the following methods: Mystring (String s) a constructor that takes as input parameter a String MyString (char [1 array) a constructor that takes as input a character array. public int length() returns the length of the string public boolean isEmpty() r true if the length of the string is 0. eturns public Mystring substring(int start, int end) returns a new object of the class MyString that is a substring of the current string public Mystring substring(int start) returns a new object of the class MyString that is a substring of the current string. public char charAt (int position) returns the character at the specified position public int indexof char character) returns the position of the first occurrence of the character or -1 if the character is not found public MyString replace (char oldChar, char newChar) returns a new object of the class MyString where each occurrence of oldCHar is replaced by newChar. DO NOT modify the original object In some of this methods, the input parameter can be outside the boundaries of the string. Check the value of the parameter and if it is outside the boundaries, throw ArrayIndexOutOfBoundsException Use the tester class to check if your code is working fine

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions