im developing a language converter
so i want to do like this

source | target (this is only example)
aa | q
bb | w
cc | e

im using netbeans ide
i have a one textfield for input strings and textarea(i used textarea becoz i dont know how to append textfield) to display converted string
this is my code

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String source ;
jtextArea1.append(source.replace("aa", "q"));
jtextArea1.append(source.replace("bb", "w"));
jtextArea1.append(source.replace("cc", "e"));

this dosent work
if i input aabb i get qbbaaw
i want qw

how to fix this????
plzz help me

Try debugging your code by making the method calls separately and printing out the values or the variables as they are executed. You must not be using the methods correctly. By doing each step by itself and examining the results you will see what you are doing wrong.

jtextArea1.append(source.replace("aa", "q"));

String str1 = source.replace("aa", "q");
// here print out str1 and source

do the same for the next two also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.