Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: All help would be much appreciated!!

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation All help would be much appreciated!!

    Hi,

    In the box below is what I have to do. I'm having errors in my code and can't figure out what is wrong. If anyone can help that'd be great.
    Last edited by Rkelly155; April 10th, 2012 at 09:05 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    I'm having errors in my code and can't figure out what is wrong.
    Please explain. If you are getting error messages, please copy the full text and paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    4 errors found:
    [line: 57]
    Error: char cannot be dereferenced
    File: [line: 71]
    Error: char cannot be dereferenced
    File: [line: 84]
    Error: char cannot be dereferenced
    [line: 98]
    Error: MyString.java:98: incompatible types
    found : java.lang.String
    required: MyString
    Last edited by Rkelly155; April 10th, 2012 at 09:06 PM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    Can you copy the full text of the compiler's error messages? I would expect them to look like this:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    Notice that the error message includes the source line and a ^ beneath where the error is.

    For this error:
    char cannot be dereferenced
    You can't call a method using a char variable. For example: 'a'.aMethod() is not valid
    "a".length() is valid because "a" is a String object

    What statement is line 98?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    I still don't understand. I need to call string[i] because it's the array that I need to use.

    and line 98 is
    Last edited by Rkelly155; April 10th, 2012 at 09:05 PM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    You posted 8 lines. Which one is line 98?

    The method is defined to return a MyString object. Is that what you want it to do?
    Where is there a MyString object that can be returned?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    The MyString object that gets returned is what I have to create in the tester class I think. I have to create a class with these methods than make a tester class that will use these methods on a string that I will give in a constructor. Hopefully that made sense.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    To create a MyString object you need to use the new statement:
    MyString myStr = new MyString(<SOME ARGS HERE?>);
    then at the end of the method:
    return myStr;
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    I'm just struggling with the methods that need to be created. Is there anyway, based off of my code, that you can see I did something wrong? Or how would you code the methods?

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    Please define what the method is supposed to do. What arguments does it receive, what processing does it do and what does it return?
    If there is more than one method, do the above steps for each method.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    I have included the methods i need to create in the class all the way above in the box above my code that I have so far.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    If you have definitions of what the methods should do, then you need to design the code for each one before you code it.
    Pick one, design it, code it, compile it test it. When it works, move on to the next one.
    Last edited by Norm; April 10th, 2012 at 08:50 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: All help would be much appreciated!!

    Cross posted at: MyString Help
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Junior Member
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: All help would be much appreciated!!

    rewrite your code then write your error...

Similar Threads

  1. applet is not initialized. Help will be appreciated
    By NewAtJava in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 20th, 2012, 07:03 PM
  2. Replies: 3
    Last Post: November 18th, 2011, 08:33 AM
  3. Help really appreciated
    By Thermal_Vent in forum Java Theory & Questions
    Replies: 1
    Last Post: November 15th, 2010, 08:42 AM
  4. any help is much appreciated
    By Schmitz14 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2009, 07:51 PM
  5. Need a little help. would be greatly appreciated
    By ryan29121 in forum Java Theory & Questions
    Replies: 4
    Last Post: September 27th, 2009, 02:03 PM