Skip to content
Advertisement

Making a concat operator to add char array to a string. Printing a reference variable of a string object

So far, if I try to use the concat operator I get this error Tester.java:14: cannot find symbol symbol : method concat(MyString) location: class MyString System.out.println(hello.concat(goodbye)); // prints “hellogoodbye”

and when I try to print the “hello” object of MyString I get MyString@558ee9d6 I feel like its soo close to working..

JavaScript

public class Tester { public static void main (String[] args)

JavaScript

Advertisement

Answer

You are trying to print an Object :

JavaScript

In this case your MyString class

Make the get method to your variable oneString.

JavaScript

and then call

JavaScript

Another problem

JavaScript

You concat method receives a string and not a MyString class

You may want to do this

JavaScript

or

JavaScript

Final result:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement