Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to better understand array operations?

User_X0INSSep 20 2021

Hello,
I need to output any common elements that are in two arrays I instantiated in my array that randomly range from anywhere between 0 to 100, along with needing to output the common elements that will be deleted. While I previously compiled my program successfully until outputting the combination of the two arrays discussed above, I do not know how to incorporate my needed range or remove the common elements and create the output of these deleted elements. I also had the error "bad operand types for binary operator +" when attempting to print. Here is the code for my program:
/*
*I need to incorporate the requirements above into the following code
*/
//These classes allow for instantiating arrays and randomizing numbers
import java.util.Arrays;
import java.util.Random;

public class ArrRanProgress {
//This method declaration will carry out a Selection Sort Algorithm for necessary swapping
public static int[] SelectionSort(int[] array){

for(int i = 0; i \< array.length; i++){  
  int index = i;  
     
  //The smaller element swapped will be in its correct place  
  for (int j = i + 1; j \< array.length; j++){  
    if (array\[j\] \< array\[index\]){  
      index = j;  
    }  
  }  
     
  int leastValue = array\[index\];  
  array\[index\] = array\[i\];  
  array\[i\] = leastValue;  
}  
return array;  

}

public static void main(String args[]) {

//Random keyword will allow for choosing random values
Random generate = new Random();

//Declaring ListA and ListB arrays that allocate 50 integers each in memory
int[] ListA = new int[50];
int[] ListB = new int[50];

//for loops will initialize random values
for (int i = 0; i < ListA.length; i++){
ListA[i] = generate.nextInt();
}
System.out.println(Arrays.toString(ListA));
System.out.println("");

for (int i = 0; i < ListB.length; i++){
ListB[i] = generate.nextInt();
}
System.out.println(Arrays.toString(ListB));
System.out.println("");

//New arrays will be instantiated from old arrays in order swap elements into order
int[] OrderedListA = SelectionSort(ListA);
int[] OrderedListB = SelectionSort(ListB);

System.out.println(Arrays.toString(OrderedListA) + "\n");
System.out.println(Arrays.toString(OrderedListB) + "\n");

//Need assistance to combine the two ordered arrays to make the TheList array
int[] TheList = new int[OrderedListA+OrderedListB];
System.out.println(Arrays.toString(TheList));
}
}

Comments

Elco

It are not the tables :

CSF_ACCESS_HOURS_B

CSF_ACCESS_HOURS_TL

Elco

I don't know how I can do the relation with party_id and customer_name

I have now this SQL code:

SELECT

       hp.party_name

     , hca.account_number

     , hca.cust_account_id

     , hp.party_id

     , hl.address1

     , hl.address2

     , hl.address3

     , hl.city

     , hl.state

     , hl.country

     , hl.postal_code

         

FROM   hz_parties hp

     , hz_party_sites hps

     , hz_locations hl

     , hz_cust_accounts_all hca

     , hz_cust_acct_sites_all hcsa

     , hz_cust_site_uses_all hcsu

WHERE  hp.party_id = hps.party_id

AND    hp.party_id = hca.party_id

AND    hcsu.cust_acct_site_id = hcsa.cust_acct_site_id

AND    hca.cust_account_id = hcsa.cust_account_id

Elco

Does anybody has an idea?

Thanks in advange

Regards

Elco

1 - 3

Post Details

Added on Sep 20 2021
0 comments
54 views