Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:19:53+00:00 2026-06-14T07:19:53+00:00

So far, if I try to use the concat operator I get this error

  • 0

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

public class MyString

{
     private char[] charString;
     private String oneString;


      public  MyString(String string) 
      {
        this.oneString = string;


      }

//second constructor for overloading
    public MyString(char[] s) 
    {

        this.charString = s;
        this.oneString = charString.toString();
    }

//methods
    public String toString( char [] s)
    {
        return new String(s);
    }

    public char charAt(int i) {

        char [] temp = new char[oneString.length()];
        for ( int j = 0; j < oneString.length() ;  j++)
        temp[j] = oneString.charAt(i);
        return temp[i];
    }

    public String concat ( char[] s)
    {
        s.toString();
        String result = oneString + s;
        return result;
    }

    public String concat ( String s)
    {
        String result = oneString + s;
        return result;
    }


}

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

    {
    MyString hello = new MyString("hello");
    System.out.println(hello);  // right now this prints MyString@558ee9d6
    System.out.println(hello.charAt(0));    // works, prints 'h'
    char[] arr = {'g','o','o','d','b','y','e' };
    MyString goodbye = new MyString(arr);
   // System.out.println(hello.concat(goodbye)); // i can't get this line to work
    System.out.println(hello.equals(goodbye)); // works, prints false
    System.out.println(hello.equals(hello));  //works, prints true
    }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:19:54+00:00Added an answer on June 14, 2026 at 7:19 am

    You are trying to print an Object :

    System.out.println(hello);  // right now this prints MyString@558ee9d6
    

    In this case your MyString class

    Make the get method to your variable oneString.

    public String getOneString() {return this.oneString;}
    

    and then call

    System.out.println(hello.getOneString());
    

    Another problem

    System.out.println(hello.concat(goodbye));
    

    You concat method receives a string and not a MyString class

    You may want to do this

    System.out.println(hello.concat(goodbye.getOneString()));
    

    or

    public String concat ( MyString myS)
        {
            String s = myS.getOneString();
            String result = oneString + s;
            return result;
        }
    

    Final result:

    public class Tester { public static void main (String[] args)
    
        {
        MyString hello = new MyString("hello");
        System.out.println(hello.getOneString());
        System.out.println(hello.getOneString().charAt(0)); 
        char[] arr = {'g','o','o','d','b','y','e' };
        MyString goodbye = new MyString(arr);
        System.out.println(hello.concat(goodbye.getOneString()));
        System.out.println(hello.equals(goodbye)); // works, prints false
        System.out.println(hello.equals(hello));  //works, prints true
        }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error when I try and use an MS Access database
Programming is (so far) just a hobby for me, so I try to find
So, I thought I'd try my luck on ASP.NET. I didn't get very far
I'm trying to get a dict out of a method, so far I'm able
I wanted to try combining use of memcmp with multithreading there's this code that
As far as I know, I put in the correct try catch statements to
As far as I can see this is not the case, however, I thought
I try to use the new POCO capabilities of EF 4.0 in combination with
For a little project about XML I try to use HTML5 as it has
I'm playing around in Haskell to try and get the hang of it. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.