Home Tutorialhelp Comment Clarification on equals method of StringBuffer

 
 

Comment

Sivakumar Ganti
Clarification on equals method of StringBuffer,
July 14, 2010 at 4:55 PM

// spring buffer will evaulate to false while comparing two strings.But in the above tutorial it is said as true.

public static void main(String[] args) {


StringBuffer sb = new StringBuffer("hello1");
StringBuffer sb1 = new StringBuffer("hello1");



// this would be false because String buffer does not have
// an equals method and the control would pass on to StringBuffer
// equal method.
// The Objects equal method will not know it wwere just two
// string , they are just two objects.
if(sb.equals(sb1)){
System.out.println("String buffer equals");
}else
System.out.println("String buffer not equals");



// == equal compares the memory location and hence since
// they are two different objects it will be false.
if(sb == sb1){
System.out.println("String buffer == equals");
}else
System.out.println("String buffer not== equals");


}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

StringBuffer and StringBuilder
and sbu2 will get different refence ids; here equals method of Object class...StringBuffer and StringBuilder  package org.day.strings; import...[] args) { StringBuffer sb1 = new StringBuffer(); sb1.append 

Java Beginners

StringBuilder v/s StringBuffer - Java Beginners
between StringBuilder & StringBuffer classes. I know that StringBuffer... inefficient. StringBuilder (or StringBuffer) are better choices in these cases... of programming can be used. StringBuilder is basically identical to the older StringBuffer 

Java-Tutorials

Differences between the String, StringBuilder, and StringBuffer classes
Differences between the String, StringBuilder, and StringBuffer classes StringBuffer versus String Java provides the StringBuffer and String classes... for the concatenation creates a StringBuffer object, then invokes its append method 

Java Beginners

StringBuilder v/s StringBuffer - Java Beginners
StringBuilder v/s StringBuffer  Hi, Thank you for your prompt... Threads run simultaneously. But in case of BOTH StringBuilder & StringBuffer...(); System.out.println(str); StringBuffer read = new StringBuffer("I JAVA." 

Java Beginners

StringBuffer - Java Beginners
StringBuffer  Hi, Thank you so much for answering my previous question regarding StringBuilder And StringBuffer. But,while using more than one...-threaded applications(i.e. StringBuffer)? Please give example(code) and explain 

Java Beginners

String and StringBuffer - Java Beginners
; Hi vijay Java provides the StringBuffer and String classes.... Simply stated, objects of type String are read only and immutable. The StringBuffer... performance difference between these two classes is that StringBuffer is faster 

Java Interview Questions

equals and hashcode
to the equals() method because it is inherited from the Object class. However, this default... can override the default implementation of the equals() method defined...equals and hashcode  Could you please explain me why equals 

Java Tips and Examples

Summary
Summary       You have been introduced to the basics of Java language providing a great amount... be eager to discover more about Java in the succeeding chapters. The course 

Programming Tutorials

equals method in java
Description: The equals method found in java.lang.object. It is use to check  state(data) of object not identifying the location in Memory of the object. It return the Boolean value. In other way it compare content of  

Java Beginners

Equals() and Hashcode() - Java Beginners
Equals and HashCode() are the methods of Object class. The Equals() method returns...Equals() and Hashcode()  What is Equals() and Hashcode()? what... these methods while using Hashtable? Please Explain it detaily along with an java 

Java Tips and Examples

Java - StringBuffer class in Java
Java - StringBuffer class in Java       In this example you will learn about StringBuffer class. This example explains how you can use functions provided by the StringBuffer 

Programming Tutorials

Use of equals() method of ByteBuffer class in java.
Use of equals() method of ByteBuffer class in java.  In this tutorial, we...; The allocate(..)method allocate a new byte buffer. boolean equals(object obj) The equals() method tells this buffer is equals or not to another 

Programming Tutorials

Use of equals() method of  FloatBuffer class in java.
Use of equals() method of  FloatBuffer class in java.  ... equals(object obj) The equals() method tells this buffer is equals... C:\>java FloatEqualDemo Equals Equals Not equals 

General

Java writer api
,  field summary, constructor summary and method summary. Abstract Writer... package.    Writer method summary Abstract class Writer possess several... Java writer api       

Java Beginners

Equals()
Equals()  What is role of equals() method in camparator interface 

Programming Tutorials

Use of equals() method of LongBuffer class in java.
Use of equals() method of LongBuffer class in java.  In this tutorial, we...(..)method allocate a new long buffer. boolean equals(object obj) The equals() method tells this buffer is equals or not to another 

Programming Tutorials

Use of equals() method of IntBuffer class in java.
Use of equals() method of IntBuffer class in java.  In this tutorial, we...(..)method allocate a new int buffer. boolean equals(object obj) The equals() method tells this buffer is equals or not to another 

Programming Tutorials

Difference between == and equals method in java
Description: For comparing equality of string ,We Use equals() Method... "equals()" method .  "==" compares the reference value of string object whereas equals() method is present in the java.lang.Object 

Java Technology Tutorials

Java file equals
Java file equals This section illustrates you the use of method equals... file class objects using equals() method. This method checks whether...); } } Through the method equals(), you can check the equality of two file 

Java Beginners

further clarification needed - Java Beginners
further clarification needed  Dear Experts, I refer to the last answer you have written to me. The good news is that there's no error already but the code is still not working for me. As Tsuch, I hope to clarify about 

Java Beginners

stringbuffer - Java Beginners
DeleteString { public static void main(String args[]) { StringBuffer sb = new StringBuffer("Rose India Tech"); //Removes the characters at index 10 to 15 in the StringBuffer. sb.delete(10, 15); System.out.println("After delete 

Java Interview Questions

AutoBoxing,==,!=,equals() - Java Interview Questions
AutoBoxing,==,!=,equals()  Hi, I am really confused of ==,!=,equals() operations on Autoboxing the new feature in java 5.0 . Can any one tell me....  Java language have 2 data types . 1.Primitive type. 2. Reference 

Java Beginners

StringBuffer - Java Beginners
StringBuffer  Can any one help with this naughty problem? Replacing a character with two characters in a StringBuffer. Replacing a character...;} converting the StringBuffer using charArray[] also worked well, but not where 

Programming Tutorials

ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
Use of equals() method of ShortBuffer class in java.  In this tutorial.... boolean equals(object obj) The equals(...) method tells this buffer.... It provides the following methods: Return type Method 

Core Java

String reverse in java
; java API provides StringBuffer and StringBuilder  reverse() method which... StringBuffer and StringBuilder methods. For that we will do it by recursive way as well...String reverse in java In this section we are going to discuss about how 

Java Beginners

Overriding equals and hashCode in Java
Overriding equals and hashCode in Java  Overriding equals and hashCode in Java 

Java Beginners

String and stringbuffer object - Java Beginners
String and stringbuffer object  Hi, What is the basic difference between string and stringbuffer object? Thanks   Hi Friend... be changed while StringBuffer class is used to represent characters that can 

Core Java

Difference between equals() and == ?
equals() method in java. The equals() method which is defined in object class. equals() method behave same as the equality operator but rather then checking.... But one more difference is that equals() is a method and "= =" 

Java Beginners

'String' vs 'StringBuffer' - Java Beginners
'String' vs 'StringBuffer'  What should i use String or StringBuffer?  Hi, First you need to rectify the question. Because StringBuffers... StringBuffer when you are append different data to the same StringBuffer object 

Java Beginners

hashcode() and equals() - Java Beginners
hashcode() and equals()  plesae give an example of hashtable using equals() and hashcode()?  Hi Friend, Try the following code...) {this.id = id;} public int hashCode() { return id;} public boolean equals 

Java Interview Questions

hashcode() and equals() - Java Interview Questions
hashcode() and equals()  can you give one hashtable prog using equals() and hashcode()?PLease..thanks in advance 

Java Interview Questions

Equals() and Hashcode() - Java Interview Questions
Equals() and Hashcode()  What is Equals() and Hashcode()? what... these methods while using Hashtable? Please Explain it detaily along with an java... of hashtable using equals() and hashcode 

JSP Servlet Questions

clarification in jsp - JSP-Servlet
clarification in jsp  Hi did jsp supports post method to send values to next jsp? if possible how to use post method in jsp?and what is the default method(get/post) of jsp?  Hi Friend, Yes jsp supports Post 

Java Interview Questions

Interview Tips - Java Interview Questions
Interview Tips  Hi, I am looking for a job in java/j2ee.plz give me interview tips. i mean topics which i should be strong and how to prepare. Looking for a job 3.5yrs experience 

Java Beginners

Constructors .equals method
Constructors .equals method  Hi, my two dates never match using .equals method and two different constructors. o/p is like examples.Pdate@192d342Blah dateexamples.Pdate@6b97fd Code: package examples; public class Pdate 

Java Beginners

Constructors .equals method
Constructors .equals method  Hi, my two dates never match using .equals method and two different constructors. o/p is like examples.Pdate@192d342Blah dateexamples.Pdate@6b97fd Code: package examples; public class Pdate 

General

Java BigDecimal equals example
Java BigDecimal equals example       Method evaluates bigdecimal object values as well as the scales allocated to the values. Method returns true only when both bigdecimal 

Free Magazine

Tips & Tricks
Tips & Tricks          Here are some basic implementations of java language, which you would...?? You got it right! The program below runs without the main method. Here we have 

Free Magazine

Tips & Tricks
Tips & Tricks           Splash Screen in Java 6.0 Splash screens... of the application. AWT/Swing can be used to create splash screens in Java. Prior to Java SE 

Core Java Tutorials

Write a method which will remove any given character from a string?
. In this tutorial we have used StringBuilder is a mutable sequence of character. It is used as a replacement of StringBuffer. StringBuilder is not synchronized and uses...Write a method which will remove any given character from a string 

Java Interview Questions

Java string buffer
Java string buffer  what is stringBuffer and StringBuilder 

Java Tips and Examples

Creation of StringBuffer
Creation of StringBuffer      ... we have used the following StringBuffer Constructors. StringBuffer() //Default Constructor with 16 characters set StringBuffer(String s) //String to String 

Hibernate Questions

Case-insensitive equals using Hibernate Criteria.
Case-insensitive equals using Hibernate Criteria.  How to use Case-insensitive equals with Hibernate Criteria?   The Case Insensitive... create Persistent class Employee.java‚??Hibernate uses the Plain Old Java Object 

Java Interview Questions

StringBuffer
StringBuffer  What's the difference between these two formats? String string=args[0]; String reverse = new StringBuffer(string).reverse().toString(); String string=args[0]; StringBuffer rev = string.reverse(); String 

Java Interview Questions

difference b/w == and equals()
address whereas the equals() method is used to compare the values of the object...difference b/w == and equals()  what is the difference between == operator and equals()   Hi Friend, The == operator checks if the two 

Free Magazine

Tips 'n' Tricks
Tips 'n' Tricks           Download files data from many URLs This Java program... arguments separated by space. Java provides URLConnection class that represents 

Core Java

Concatenate Two Strings in java
Concatenate Two Strings in java We are going to describe how to concatenate of two string. we have use for concat() method, this method joints of two string...) method it means add the two String first-to-end. You can  use anther  

Java Beginners

java method
java method  can we declare a method in java like this static { System.loadLibrary("nativelib"); } i have seen this in a java learning E book. i don't understand the static { } plz help me. what kind of method 

Java Tips and Examples

Appending String in java
. Methods summary for StringBuilder append() method which take any data type... appending string in java. Java provide a method called append.... StringBuilder are in replacement for StringBuffer where synchronization is applied  

Free Magazine

Tips and Tricks
Tips and Tricks        ... in Java Java provides a lot of fun while programming. This article shows you how... and keyboard related operation through java code for the purposes of test automation, self 

Free Magazine

Tips and Tricks
Tips and Tricks           Send data from database in PDF file as servlet response... is a java library containing classes to generate documents in PDF, XML, HTML, and RTF 

Java Tips and Examples

String Buffer insert and append example
:\vinod\Math_package>java AppendInsert StringBuffer insert and append... with StringBuffer and append data to it. The StringBuffer is a class that implements... the insert() method that provides the facility for adding the data in any 

Java Beginners

java method - Java Beginners
java method  Plz help me on toString() in java  Hi Friend, The Object class provides the method toString() that returns the string..., the toString() method of the object is automatically called. Thanks 

Java Beginners

java method - Java Beginners
java method  hi friends, Is there any default return type for methods in java?  There is no default return type in java, as a user you have to specify the return type even void 

Java Beginners

java method - Java Beginners
java method  i wanna explation about a method for example... Mail[] getAllMails(String userName) I WANNA EXPLATION ABOUT ABOVE METHOD CAN U... and Tutorials on Java Mail visit to : http://www.roseindia.net/javamail/ Thanks 

Java Beginners

pass method reference in java
pass method reference in java  How to pass method reference in Java 

JavaScript Questions

Small clarification
 

Java Beginners

class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java 

Java Beginners

Using throw in java method
Using throw in java method  using throw with method implies what 

Java Beginners

try catch method in java
try catch method in java  try catch method in java - when and how should i use the try and catch method in Java ?   Please visit the following links: http://www.roseindia.net/help/java/t/java-try.shtml http 

Java Beginners

Java making a method deprecated
Java making a method deprecated  java making a method deprecated In Java how to declare a method depricated? Is it correct to use depricated... or method in Java. Instead of it you can use alternatives that exists. Syntax 

Java Interview Questions

method inside the method??
method inside the method??  can't we declare a method inside a method in java?? for eg: public class One { public static void main(String[] args) { One obj=new One(); One.add(); private static void add 

Java Beginners

Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How 

Java Beginners

getch() method in java
getch() method in java  does someone know how can i obtain the getch() function in java 

Java Beginners

Generic Method - Java Beginners
Generic Method  I want simple java program for Generic Method with explanation 

Java Beginners

Destroy method in java - Java Beginners
Destroy method in java  Hi, What is the implementation of destroy method in java.. is it native or java code? Thanks   Hi Friend, This method is not implemented. Thanks 

General

How to Invoke method using Reflection API of Java?
; method of StringBuffer class Now we will learn how to call the "append" method of StringBuffer class using the Java Reflection API. Here is the signature of the append method of the StringBuffer class: public StringBuffer 

Java Beginners

Class and method question, Java?
Class and method question, Java?  Consider a Java class that you... Prompt string** and the following method: getValue displays the prompt and reads..., the method should display an error message and ask the user for a new value 

Java Interview Questions

Method decleration in java
Method decleration in java  What is the catch or declare rule for method declarations 

General

Method
of method in java object-oriented technique first one is the Instance method... by method's name and the parameter types. Java has a powerful feature which... Method       

Java Interview Questions

getch() method in java
getch() method in java  does someone know how can i obtain the getch() function in java?   Hi Friend, In java, you can use the method next() of Scanner class. Here is an example: import java.util.*; class Hello 

Java Interview Questions

StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable 

Java Beginners

Static method in java - Java Beginners
Static method in java  What are static method in Java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml Hope that it will be helpful for you 

Java Interview Questions

Java static method
Java static method  Can we override static methods 

Java Interview Questions

Java synchronized method
Java synchronized method  What are synchronized methods and synchronized statements 

Java Beginners

Java Method Overloading - Java Beginners
Java Method Overloading  can method be overloaded in subclass or not?  Hi Friend, Yes A subclass can overload the methods.For Example...: http://www.roseindia.net/java/master-java/method_overloading.shtml Thanks 

Java Interview Questions

Method Overloading
Method Overloading  In java can method be overloaded in different class 

Java Interview Questions

Method Overloading
Method Overloading  In java can method be overloaded in different class 

Java Beginners

method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding 

Java Beginners

method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding 

Java Beginners

Finalize method in Java - Java Beginners
Finalize method in Java  Hi, What is the use of Finalize method in Java? Give me few example of Finalize method. Thanks   Hi Friend, Java uses finalize() method for Garbage collection. Example: import 

Java Beginners

Method overloading in java program
Method overloading in java program  How can we use method overloading in java program?   Method overloading:?In method overloading methods have same name but different type of parameters. Here is an example of method 

Java Beginners

Finalize method - Java Beginners
method, please can you suggest me a way out.   Hi method, finalize : Every class inherits the finalize() method from java.lang.Object the method... to the object exist the Object finalize method performs no actions but it may 

Java Beginners

Java Code - Java Beginners
Java Code  What is the relationship between equals() method & hashCode 

JSP Servlet Questions

how to insert a summary values in grid
how to insert a summary values in grid  how to insert a summary value in grid 

Java Beginners

method overloading - Java Beginners
method overloading   Write a program to demonstrate the method... }  Hi Friend, In Java, the methods having the same name within... is referred to as Method Overloading. In the given example, we have defined 

Java Beginners

customize method in java
customize method in java  hi there i want to create one customize method in which any no of parameters can be pass e.g the limit is 13 and if user wants to enter 3 inputs then that much can only be proceed so can i have solution 

Java Beginners

Java Method with arrays
Java Method with arrays  My assignment is to write a java method..., write a program to test your method. my main method code is : public class...]; currentSmallestIndex = i; } } return currentSmallestIndex; } //main method 

Java Beginners

main method
main method  Why is the java main method static 

Java Beginners

java swings - Java Beginners
java swings  hi, I need the listbox value enable and disable... searchText3 = (char) 34 + ""; String substringofqueue[] = new String[50]; StringBuffer displayqmrlist = new StringBuffer(); String substringofqueuetemp = null 

Java Beginners

java swings - Java Beginners
java swings  Hi, For the same code .... If i select the first... = (char) 34 + ""; String substringofqueue[] = new String[50]; StringBuffer displayqmrlist = new StringBuffer(); String substringofqueuetemp = null; String st 

Java Beginners

java swings - Java Beginners
java swings  hi, This is my code. I need the code for disable... substringofqueue[] = new String[50]; StringBuffer displayqmrlist = new StringBuffer(); String substringofqueuetemp = null; String st=""; ArrayList selected1 

Java Beginners

Static method
Static method  what is a static method?   Have a look at the following link: Java Static Method 

JavaScript Questions

Java Script location.replace method
Java Script location.replace method  Hi, What does `Print `{<SCRIPT LANGUAGE="JavaScript"> location.replace("} & urlpop & {","BOTTOM") </SCRIPT>} this mean as this is written in an Lotus Script agent and I 

Programming Tutorials

Dojo Tool tips
Dojo Tool tips           In this section, you will learn about the tool tips and how to developed it in dojo.  Tool tips :  This is a GUI 

Programming Tutorials

Dojo Tool tips
Dojo Tool tips           In this section, you will learn about the tool tips and how to developed it in dojo.  Tool tips :  This is a GUI 

Java Beginners

method - Java Beginners
method  Method Sir, I am confusing in this sentence and did not understood clearly about a method that returns object and reference and unable.... Suppose, for instance, that you want to write a method to return what 

JavaScript Questions

java program on recursive method
java program on recursive method  in how many ways can you make change for one dollar(100 cents) using pennies(1-cent coins), nickels(5 cents), dimes(10 cents),and quarter(25 cents)? the coins must add up to the exact total 

Java Beginners

calling method - Java Beginners
calling method   class A{ public void fo(){ class B{ public void fo1(){ System.out.println("fo1 of class B... static void main(String args[ ]){ } } I Want to call method fo1 

Java Beginners

clone method - Java Beginners
clone method  I want to copy a reference which the class name is B and the variable name is A. I used clone method.After I have the class name C which is same with b class. C=(A) B.cloneObject(); I make a clone method 

Advertisements Advertisements
 

 

 

DMCA.com