java - I have been working on this code and I called my method replaceLessThan(x,e), and I can't properly write this method -


public class arrayexamples {      public static void main(string[] args) {     int c = 3;     int d =2;     system.out.println("c " + c + " d " + d);     swapints(3,2);         int [] = {1,2,3};         int [] b = {2,2,3};         int [] x = {3,45,17,2,-1,44,9,23,67,2,-6,-23,-100,12,5,1212};         int e = 12;         system.out.println();         ( int z: a){             system.out.print( z + " ");          }         system.out.println();         ( int y: b){             system.out.print( y + " ");         }         swapintarrays (a,b);         system.out.println();         ( int z: x){             system.out.print( z + " ");         }          replacelessthan(x,e);     }       public static void replacelessthan(int[] x, int e) {             system.out.println();         (int counter = 0 ; counter<x.length; counter++){             if ( x[counter] < e){                  system.out.print (x[counter] + " ");             }          }      }       public static void swapints(int c, int d){         int temp = c;         c=d;         d=temp;         system.out.println("c " + c + " c " + d);       }      public static void swapintarrays (int []a, int []b){         system.out.println();         for(int i1=0; i1 < a.length; i1++){             int temp = a[i1];             a[i1] = b[i1];             b[i1]= temp;              system.out.print(a[i1] + " ");          }         system.out.println();          for(int i1=0; i1 < b.length; i1++){             system.out.print(b[i1] + " ");         }          system.out.println();     }  } 

my other methods working fine can't figure out how manipulate int[]x array 12 replace numbers less 12. can numbers less 12 int[]x print can't 12 replace numbers less 12

modify replacelessthan method given below replace elements less e.

    public static void replacelessthan(int[] x, int e) {             system.out.println();         (int counter = 0 ; counter<x.length; counter++){             if ( x[counter] < e){                 x[counter] = e; // add line replace elements.             }             system.out.print (x[counter] + " "); // move statement out of if condition                      } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -