jamaica

Java - removing first character of a string

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In Java, I have a String: Jamaica I would like to remove the first character of the string and then return amaica How would I do this? 回答1: Use the substring() function with an argument of 1 to get the substring from position 1 ( after the first character) to the end of the string (leaving the second argument out defaults to the full length of the string). "Jamaica".substring(1); 回答2: public String removeFirstChar(String s){ return s.substring(1); } 回答3: Use substring() and give the number of characters that you want to trim from front.