473,382 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help with ArrayLists parameters?

This is what I have so far. Am I on the right track because I am kind of confused? I understand what it is asking for, but I do not really know how to put that in code. I received the error: type ArrayList does not take parameters at line 9 and 11. Can someone help?


Write a method called removeLowerThan that takes a double, number,and an integer, length, as parameters. The method should create an ArrayList and fill it with length number of Doubles. The Doubles should be Random! You must use the Random class. The method should then remove all values that are less than number and return the revised ArrayList.

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. public class ArrayList
  3. {
  4.  
  5.     public ArrayList()
  6.     {
  7.     }
  8.  
  9.     public ArrayList<Double> removeLowerThan(double number, int length)
  10.     {
  11.         ArrayList<Double> list = new ArrayList<Double>();
  12.         Random Random = new Random();
  13.         for (int i = 0; i <length; i++)
  14.         {
  15.             double r = (double)Random.nextInt(length);
  16.             list.add(r);
  17.         }
  18.         System.out.print(list);
  19.         int j = 0;
  20.         while (j < length)
  21.         {
  22.             if (list.get(j) < number)
  23.             {
  24.                 list.remove(j);
  25.             }
  26.             j++;
  27.         }
  28.         for (Double d : list)
  29.             System.out.print(d);
  30.  
  31.     return list;
  32.     }
  33.  
  34. }
  35.  
Jan 14 '11 #1
1 1784
horace1
1,510 Expert 1GB
you have named your class ArrayList the same name as the ArrayList class in java.util
Change the name of you class
Jan 14 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Edward King | last post by:
Hi! I am trying to achieve the following: I have a number of help pages (in the format help_nn.php where nn=helpid). I want to be able to open a particular help page by calling the function...
1
by: Julie | last post by:
Suppose a string of the following format: /field=value string /field2=value string2 /field3=value string3 where field is , , and _ value string is any alphanumeric text that doesn't...
4
by: Tim::.. | last post by:
Can someone tell me a better way or give me a link that shows a better way to create large numbers of SQL parameters... Example... A better way to write this code! <code> Sub...
1
by: scorpion53061 | last post by:
I would like a suggestions on the best way to write 2 arraylists to a datagrid or if it is even possible. I would want to do AList.Item(0) = BList.Item(0) and trying to write them both to a...
3
by: salih ataoz | last post by:
hi i need help about parameters i have a login form and a component i put username,password texboxes and one login button on the login form on the component i drag and drop a...
5
by: drdave | last post by:
I would like to have ten arraylists created within a loop.. is there a conversion or something I can do to acheive this.. pseudo: Dim counter As Integer = 0 Dim ArrName As ArrayList ...
1
by: neon123 | last post by:
i need to pass two string parameters in bat file.....in visual basic 6 i am trying thgs like Shell "N:\aa.bat abc bcd " here abc and bcd are two string variables but its not...
1
by: cmc12 | last post by:
Hi, I want to open MqSQL and run a command using a DOS batch script like this, it runs but doesn't update dB. any ideas is the command line tag -e correct? mysql -e "USE <database name" -e...
1
by: leonald007 | last post by:
Hi, i have problem with the Execute statement at db.Execute (LDelete). The debugger told mi itz too few parameters Expected 1. Can any1 help mi.. thx in advance... Private Sub Command4_Click()...
0
by: Wanxi | last post by:
Hi everyone, I am testing one of the example -> <UsingTheSerialPort> at VB101SamplesBCL2. But there are some error which i don't know how to edit. I found some post that having the same problem...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.