Data Type & Variables (Part 2)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:id="@+id/textd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp"
android:gravity="center"/>
<TextView
android:id="@+id/textdis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp"
android:gravity="center"/>
</LinearLayout>
JAVApackage com.abirsoft.sectontow;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
String my_string;
String mystring1 = "hello world";
int count = 10;
int count3;
int a1,a2,a3,a4;
int mycount = 0;
String s1 = "hello";
String s2 = "world";
int count1 = 10;
int count2 = 20;
int sum;
String mystring;
int a, b, c;
int sum1,mul;
TextView textd , textdis;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textd = findViewById(R.id.textd);
textdis = findViewById(R.id.textdis);
a=10;
b=20;
c=30;
sum1 = a+b+c;
mul = a*b*c;
textdis.setText("sum=" +sum1+ "\n multi= " +mul);
textd.setText(s1+s2);
my_string = "hello" +"world";
String mystring= s1+s2;
int sum = count1+count2;
sum = count1 +count2;
mystring = s1=s2;
String mystrinh3 = sum+my_string;
}
}
No comments:
Post a Comment