class="java" name="code">package com.ways.app.dpca.utils; public class TestTransform { public static void main(String[] args) { String s = "manf,"+ "brand,"+ "car_series,"+ "old_version_code,"+ "model_name,"+ "msrp,"+ "segment,"+ "launch_date,"+ "emissions,"+ "transmission,"+ "year,"+ "mon,"+ "mix,"+ "wholesale,"+ "avg_tp,"+ "q1,"+ "q2,"+ "q3,"+ "q4,"+ "nyear,"+ "nyear_mix,"+ "myear,"+ "myear_mix,"+ "cumulative_mix,"+ "definition_price_tier"; String strArr[] = s.split(","); String tempStr = ""; for(String str:strArr){ tempStr+=str; tempStr+=" as "; tempStr+=transform(str)+","; tempStr+="\n"; } System.out.println(tempStr); } public static String transform(String str){ while(str.contains("_")){ int i = str.indexOf("_"); if(i+1<str.length()){ char c = str.charAt(i+1); String temp = (c+"").toUpperCase(); str = str.replace("_"+c, temp); } } return str; } }
?