MainActivity.java
package com.cfsuman.me.javaexamples; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; import android.widget.RelativeLayout; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set background color for action kafe getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED)); // Get widget reference from XML layout RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl); TextView tv = (TextView) findViewById(R.id.tv); // Empty the TextView tv.setText(""); // Initialize a new string variable String alphabet = "ABCDEFGH"; tv.setText("String : " + alphabet); // Convert the String to char array char[] charactersOfAlphabet = alphabet.toCharArray(); tv.setText(tv.getText() + "\nchar array elements : "); // Iterate over the char array for(int i=0;i<charactersOfAlphabet.length;i++){ tv.setText(tv.getText() +""+ charactersOfAlphabet[i] + ", "); } } }
- java - How to convert ArrayList to Array
- java - How to convert a char to a string
- java - How to know a variable type
- java - How to compare strings
- java - How to perform string replace
- java - How to initialize string array
- java - How to initialize an array
- java - How to convert an array to a string
- java - How to clear or empty a StringBuilder
- java - How to sort an array
Komentar
Posting Komentar