您现在的位置是:首页 >

删除数组中重复的数字 Java 删除数组中重复的元素

火烧 2023-04-14 08:42:19 1027
Java 删除数组中重复的元素   我是将数组封装为类的 其中方法说明 getmax(){ //计算数据个数 getData(i t i dex)得到i dex的元素 etData(i t i dex

Java 删除数组中重复的元素  

  我是将数组封装为类的 其中方法说明 getmax(){   //计算数据个数 getData(int index)得到index的元素 setData(int index int b)设置索引为index的元素值为b

  public void noDup(){

  //循环嵌套将重复的设为 int max = this getmax()

  for(int i = i < max i ++){ for(int j = i +

  j < max j ++ ){ if (this getData(i) == this getData(j)) { this setData(i ) }

  }

  //删除value为x的所有项public void dele(int x){ int i = int max = this getmax()

删除数组中重复的数字 Java 删除数组中重复的元素

  while(!(this getData(i) == )){ if (this getData(i) == x) { for(int j = i

  j < max j ++){ this setData(j this getData(j + ))

  }

lishixinzhi/Article/program/Java/hx/201311/26961  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码