Remove a specific string from an array of string

前端 未结 5 1559
梦谈多话
梦谈多话 2020-12-03 13:45

I have an array like this:

String n[] = {\"google\",\"microsoft\",\"apple\"};

What I want to do is to remove \"apple\".

My problem

5条回答
  •  -上瘾入骨i
    2020-12-03 14:40

    import java.util.*;
    
    class Array {
        public static void main(String args[]) {
            ArrayList al = new ArrayList();
            al.add("google");
            al.add("microsoft");
            al.add("apple");
            System.out.println(al);
            //i only remove the apple//
            al.remove(2);
            System.out.println(al);
        }
    }
    

提交回复
热议问题