Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String buffer

Posted on 2003-12-11
8
Medium Priority
?
388 Views
Last Modified: 2010-03-31
Hi I have the followig method
      public String toString()
      {
        StringBuffer buff = new StringBuffer();
        buff.append("This is a test message");
        return buff.toString      
      }

This returns  "" basically nothing
but if I use
                 return new String(buff.toString());

This returns the required result.

Cant understand :(

0
Comment
Question by:applekanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 100 total points
ID: 9925363
That won't compile at the moment

>>return buff.toString      

should be

return buff.toString();      

0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 9925384
they both should return the same.
0
 

Expert Comment

by:badprogrammer
ID: 9925559
The above code wont compile
because >>> return buff.toString <<< should actually be buff.toString()
and yeah they both should give the same output.
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

Expert Comment

by:badprogrammer
ID: 9925562
Sorry it should be return buff.toString().
0
 
LVL 3

Author Comment

by:applekanna
ID: 9925608
Sorry but that was a typo there .....
0
 
LVL 3

Author Comment

by:applekanna
ID: 9925645
got it I called it just as

MyObject.toString();

Should have encapsulated it in a System.out.

Thx for ur help
0
 
LVL 92

Expert Comment

by:objects
ID: 9925656
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9928320
8-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question