How do I remove objects from an array in Java?

前端 未结 20 1417
Happy的楠姐
Happy的楠姐 2020-11-22 01:20

Given an array of n Objects, let\'s say it is an array of strings, and it has the following values:

foo[0] = \"a\";
foo[1]          


        
20条回答
  •  后悔当初
    2020-11-22 01:56

    In an array of Strings like

    String name = 'a b c d e a f b d e' // could be like String name = 'aa bb c d e aa f bb d e'

    I build the following class

    class clearname{
    def parts
    def tv
    public def str = ''
    String name
    clearname(String name){
        this.name = name
        this.parts = this.name.split(" ")
        this.tv = this.parts.size()
    }
    public String cleared(){
    
            int i
            int k
            int j=0        
        for(i=0;i

    getting this result

    a b c d e f

    hope this code help anyone Regards

提交回复
热议问题