Monday, February 16, 2009

Difference between String and StringBuffer class

Hello all , String s = "abc";
String s2 = new String("abc");
if(s==s2) // this is true
then
String s = "abc";
String s2 = new StringBuffer("abc").toString();
if(s==s2) // this condition will be false
What is the difference between this two codes.
Anyone knows the core reason behind this can put the comment here.
Thanks
Chetan Dhumane

Try this example

public class StringApps {
public static void main(String[] args){
String s = "abc";
String s2 = new String("abc");
if(s==s2)
{ System.out.println("references are equal"); }
else
{ System.out.println("references are not equal"); }
}}

what will be the output

Try this example

public class StringApps {
public static void main(String[] args){
String s = "abc";
String s2 = new String("abc");
if(s==s2)
{ System.out.println("references are equal"); }
else
{ System.out.println("references are not equal"); }
}}

what will be the output

What are string literal pools

Check out the below code

String s = "abc";
and
String s = new String("abc")

if you think that both are equal then you are wrong .
Check this link : http://www.javaranch.com/journal/200409/Journal200409.jsp#a1
Source - www.javaranch.com

Sunday, February 15, 2009

What is bytecode.in

Hi ,
bytecode.in is all about solving and getting solutions of J related stuff within minutes.
You can place your queries , let the expert do their best duty.Post your queries at appropriate forums so that our experts will try to solve the problems .While posting the queries use specific keywords and tags so that other users can find out your query while searching the forums.

If you think these forums are not sufficient so you can mail us your suggestions at care@bytecode.in.

We will put more forums to help you to post your queries to appropriate place.

Thanks ,
Chetan Dhumane

Saturday, February 7, 2009

More about bytecode

You can find more information about how bytecode is generated on
http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/

What is bytecode

Bytecode is the intermediate representation of Java programs just as assembler is the intermediate representation of C or C++ programs. The most knowlegable C and C++ programmers know the assembler instruction set of the processor for which they are compiling. This knowledge is crucial when debugging and doing performance and memory usage tuning. Knowing the assembler instructions that are generated by the compiler for the source code you write, helps you know how you might code differently to achieve memory or performance goals. In addition, when tracking down a problem, it is often useful to use a debugger to disassemble the source code and step through the assembler code that is executing.

An often overlooked aspect of Java is the bytecode that is generated by the javac compiler. Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer.

The bytecode is your program. Regardless of a JIT or Hotspot runtime, the bytecode is an important part of the size and execution speed of your code. Consider that the more bytecode you have, the bigger the .class file is and the more code that has to be compiled by a JIT or Hotspot runtime. The remainder of this article gives you an in depth look at Java bytecode.