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

Comparing integer with array list

Hello..

I need to compare an integer value with array list.
Code:
Expand|Select|Wrap|Line Numbers
  1.         if (year > 1986) {
  2.             Integer[] twelve = {1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986};
  3.             while (year != twelve) {
  4.                 year -= 12;
  5.             }            
  6.         }
The code is very bad.

Would somebody please help me?

Thank you.
Dec 20 '07 #1
4 4022
r035198x
13,262 8TB
Hello..

I need to compare an integer value with array list.
Code:
Expand|Select|Wrap|Line Numbers
  1.         if (year > 1986) {
  2.             Integer[] twelve = {1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986};
  3.             while (year != twelve) {
  4.                 year -= 12;
  5.             }            
  6.         }
The code is very bad.

Would somebody please help me?

Thank you.
An arraylist is a container that holds other objects. Comparing it with an integer does not really make logical sense. You also don't happen to have an arraylist in that code you have there. What you have is an Integer array.
Perhaps you want to test if an integer is present in an array?
Dec 20 '07 #2
samido
52
can you please post a seudo code for you problem, it happened to you to know a java objects without knowing theire uses, what are you trying to solve infect?
Dec 20 '07 #3
oh, I got it.

I could compare it by made a loop to retrieve each of array index then compare with the integer.

Yes, it's true, comparing an integer with arrays is really ridiculous. Forgive me for my bad. :)

Thank you very much for helps.

Best regards.
Dec 20 '07 #4
r035198x
13,262 8TB
oh, I got it.

I could compare it by made a loop to retrieve each of array index then compare with the integer.

Yes, it's true, comparing an integer with arrays is really ridiculous. Forgive me for my bad. :)

Thank you very much for helps.

Best regards.
Yep, you've got it now.
Dec 20 '07 #5

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

Similar topics

11
by: Dimension7 | last post by:
All, I am comparing to functions to see which is "better". In better, I mean more efficient, optimize, faster, etc. I have read other posts from other boards, but I'm not really sure of the...
9
by: mahurshi | last post by:
i have a quick question i am putting a debug flag in my program (i really dont need this feature, but i figured it might be useful when i get into trouble) so i want to check if argv is the...
4
by: Matt Billock | last post by:
Hello everyone, I am having some issues with what should be an insanely simple problem. Basically, I'm working on an implementation of the TSP algorithm (I have a static set of 5 locations, so...
11
by: Sheldon | last post by:
Hi, I have two arrays that are identical and contain 1s and zeros. Only the ones are valid and I need to know where both arrays have ones in the same position. I thought logical_and would work...
0
by: ccshine via DotNetMonster.com | last post by:
I'm working on an app that implements a Structure to store a recordset in an ArrayList. I used this setup to bind to a DataGrid and it worked out so well, I thought it might be a better solution...
21
by: Kristaps | last post by:
Hi everyone! I have some questions, maybe someone can help me... I write script for table comparing, but it works wery slovly. There is the script, can anyone give some tip how can I make this...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
25
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void...
1
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.