473,378 Members | 1,688 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,378 software developers and data experts.

Very new to programming, could use some help with arraylist

4
I have been looking through forums but cannot find out how to create the arraylist in java. B1 and B2 are two big numbers typed in by the user. here is some code:
Expand|Select|Wrap|Line Numbers
  1. final int MAX = 1000;
  2. List BigNum = new ArrayList();
  3. BigNum.add(new Integer(B1));
  4.  
  5. final int MAX2 = 1000;
  6. List BigNum2 = new ArrayList();
  7. BigNum2.add(new Integer(B2));
  8.  
  9. System.out.println(BigNum);
  10. System.out.println(BigNum2);
  11.  
my problem is that when i try to compile it, it says that the class i am writing uses unchecked or unsafe operations. then it says recompile with -Xlint:unchecked for details.

What does this mean, what am i doing wrong? im sure its some silly mistake on my part, but i am very confused and could use some input.
greatly appreciated, thanks and have a good day!
Sep 23 '07 #1
4 1216
JosAH
11,448 Expert 8TB
I have been looking through forums but cannot find out how to create the arraylist in java. B1 and B2 are two big numbers typed in by the user. here is some code:
Expand|Select|Wrap|Line Numbers
  1. final int MAX = 1000;
  2. List BigNum = new ArrayList();
  3. BigNum.add(new Integer(B1));
  4.  
  5. final int MAX2 = 1000;
  6. List BigNum2 = new ArrayList();
  7. BigNum2.add(new Integer(B2));
  8.  
  9. System.out.println(BigNum);
  10. System.out.println(BigNum2);
  11.  
my problem is that when i try to compile it, it says that the class i am writing uses unchecked or unsafe operations. then it says recompile with -Xlint:unchecked for details.

What does this mean, what am i doing wrong? im sure its some silly mistake on my part, but i am very confused and could use some input.
greatly appreciated, thanks and have a good day!
You're using Lists (ArrayLists) that can store any type of argument; that's what
the compiler is complaining about. Since version 1.5. you can use type-safe
generic containers:

Expand|Select|Wrap|Line Numbers
  1. List<BigInteger> myList= new ArrayList<BigInteger>();
  2. myList.add(myBigNumber);
  3.  
kind regards,

Jos

ps. don't start variables with a capital character; it's confusing.
Sep 23 '07 #2
award
4
thank you so much! it runs! yay:)

the only other thing i have no idea how to do, is we are supposed to have four numbers per spot on the array list. how to i break down my big number to take four numbers in at a time?
Sep 23 '07 #3
JosAH
11,448 Expert 8TB
thank you so much! it runs! yay:)

the only other thing i have no idea how to do, is we are supposed to have four numbers per spot on the array list. how to i break down my big number to take four numbers in at a time?
I don't understand what you want to ask exactly but for any number 'n', n%10000
are the rightmost four digits and n/10000 are all the digits *except* the last four
digits.

kind regards,

Jos
Sep 23 '07 #4
award
4
I don't understand what you want to ask exactly but for any number 'n', n%10000
are the rightmost four digits and n/10000 are all the digits *except* the last four
digits.

kind regards,

Jos



thank you very much for your help. i appreciate it. have a great day!
Sep 24 '07 #5

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

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
55
by: Ennixo | last post by:
hi, do you know where i can find some ebooks or websites talking about C# optimisation ? for exemple, i just learned that ++i is faster than i++. i would like to know more about the things...
4
by: almurph | last post by:
Hi, Hope I have the right forum here - apologies if I don't. I'm trying to access a ArrayList collection via an indexer inside a class called "collExample" What I want to be able to do is to...
5
by: Marc Bishop | last post by:
I'm trying to get this to work but i'm at a loss as to how. i've searched google without much help code Dim ArrCart As new ArrayList() ArrCart = CType(Session("sesCart"), ArrayList)...
6
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
3
by: carlos123 | last post by:
Ok, im having EXTREME problems, with arraylists, i simply dont understand them, yes i have read your article. Would someone just take a look at this code, i know it sucks. Look at the areas that say...
12
by: Justin | last post by:
Ok, I give up. I can't seem to construct a decent (productive) way of sorting my arraylist. I have a structure of two elements: Structure TabStructure Dim TabName As String Dim FullFilePath...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.