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
  • 64,492
  • 17
  • 108
  • 135
Mariocci Rossini
  • 97
  • 1
  • 1
  • 9

3 Answers3

2

You could do this

  device= device.substring(0, 1).toUpperCase() + device.substring(1);
Metalhead1247
  • 1,953
  • 1
  • 17
  • 27
0

try

String str ="test";
str=str.substring(0,1).toUpperCase()+ str.substring(1);
System.out.println(str);
upog
  • 4,565
  • 7
  • 35
  • 70
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
  • 10,994
  • 16
  • 64
  • 93