2

I have the following code.

String androidOS = Build.VERSION.RELEASE;
String model = Build.MODEL;
String device = Build.DEVICE;

String var = "Android "+androidOS+"\n"+model+"\n"+device;
TextView tv = (TextView)view. findViewById(R.id.textView3);
tv.setText(var);

If I want the first letter of the String device = Build.DEVICE; is capital, how can I do?

Ahmad
  • 69,608
  • 17
  • 111
  • 137
Mariocci Rossini
  • 97
  • 1
  • 1
  • 9

3 Answers3

2

You could do this

  device= device.substring(0, 1).toUpperCase() + device.substring(1);
Metalhead1247
  • 1,978
  • 1
  • 17
  • 28
0

try

String str ="test";
str=str.substring(0,1).toUpperCase()+ str.substring(1);
System.out.println(str);
upog
  • 4,965
  • 8
  • 42
  • 81
0

No one is thinking of SAMSUNG it will do nothing with this but it is expected to be Samsung

String  device  = getInintCap(Build.DEVICE);

String getInintCap(String mString)
{
    if(mString != null && mString.length() > 1)
    {
        return mString.substring(0, 1).toUpperCase() + mString.substring(1).toLowerCase();
    }
    else if(mString != null)
    {
        return mString.toUpperCase();
    }

    return null;
}

And also you shall think about ONE_TOUCH_960C or "Barak_OBAMA"

Trikaldarshiii
  • 11,174
  • 16
  • 67
  • 95