java字符串大写转小写,小写转大写

JAVA中String类提供了转大写的方法toUpperCase()和转小写的方法toLowerCase()
如下:

String a = "ABC";
system.out.println(a.toLowerCase());//abc
String b = "abc";
system.out.println(b.toUpperCase());//ABC

例题,把十进制转化为十六进制

package com.company;

import java.util.*;

public class Main {
    
    
    /*
     *十进制转六进制
     */
    public static void main(String[] args) {
    
    
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if (a >= 0) {
    
    

            System.out.println(Integer.toHexString(a).toUpperCase());

        }


    }


}

猜你喜欢

转载自blog.csdn.net/weixin_43902063/article/details/104762622