2014-09-05 27 views

回答

55

Guava通過其CaseFormat類支持此

import com.google.common.base.CaseFormat; 


public class StackOverflow25680258 { 

    public static void main(String[] args) { 
     System.out.println(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, "input_in_snake_case")); 
    } 

} 

輸出

InputInSnakeCase 
+0

我有同樣的問題。但如果單詞是helloFunnyWORLD,結果應該是hello-funny-world。番石榴解決方案不適合我。 – 2017-06-02 20:15:08

+0

出於好奇,爲什麼是類名'StackOverflow25680258'?你有某種宏嗎? – SureshS 2018-03-02 10:30:30

相關問題