package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    EditText edit_query;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edit_query = findViewById(R.id.edit_query);
        final TextView textView = findViewById(R.id.text);
        final TextView textView1 = findViewById(R.id.text1);
        final TextView textView2 = findViewById(R.id.text2);
        final TextView textView3 = findViewById(R.id.text3);
        final TextView textView4 = findViewById(R.id.text4);
        findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!edit_query.getText().toString().isEmpty()) {
                    StringBuffer stringBuffer = new StringBuffer(edit_query.getText().toString());
                    textView.setText(" default String : " + stringBuffer);
                    textView1.setText(stringBuffer.insert(0, "insert at 0  " + "tutorialspoint.com"));
                    textView2.setText("Capacity is " + stringBuffer.capacity());
                    textView3.setText("Delete : " + stringBuffer.delete(1, 3));
                    textView4.setText("append : " + stringBuffer.append(" appended to string buffer"));


                }
            }
        });

    }
}
