Java 8或更高版本,从字符数组中删除值。

huangapple go评论75阅读模式
英文:

Java 8 or higher, removing values from char array

问题

以下是翻译好的内容:

什么方法是在 char[] 核心 Java 8 中按值删除一个项的最简洁方式?

char[] c = new char[] {'a', 'b', 'c'};
   
我想要移除 'b'例如
英文:

what would be the least verbose way to remove one item by value from char[] core java 8 > ?

char[] c = new char[] {'a', 'b', 'c'}; 

I want remove 'b' for egz.

答案1

得分: 3

不特别高效,但绝对不啰嗦

char[] c = new char[] {'a', 'b', 'c'};
c = new String(c).replace("b", "").toCharArray();
英文:

Not especially efficient, but certainly not verbose

char[] c = new char[] {'a', 'b', 'c'};
c = new String(c).replace("b","").toCharArray();

huangapple
  • 本文由 发表于 2020年4月4日 04:10:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/61019686.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定