function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pg7pg7 

how to write array

hi,all

 

 

now I'm developing calculation application.

while I'm developing my application, I wonder how to write array.

 

I want to use two random numbers by using array, so I write a code like this below.

 

 

 

     public Integer getRandomNumber1() {
    
          List<Integer> random = new Integer[2];
                   
          random.set(0, Math.round(Math.random()*100));

          random.set(1, Math.round(Math.random()*100));

 

          return random.get(0);

          return random.get(1);

 

     }
 

 

I need to return two random numbers in  getRandomNumber1 class.

 

Then I display two random numbers in a visualforce page.

 

 

I appreciate any advice.

 

thanks

ColinKenworthy1ColinKenworthy1

You can't return two numbers with two return statements - your method will exit at the first return statement. Return the List of integers instead.

 

In your visualforce page use a dataTable or pageBlockTable to display the list.