Problem with arraylist

Ads
 

Problem with arraylist

I am currently working on a java project and there is an if loop within the for loop....

for(int i = 1;i < iterationsNo;i++) {

 if(areEqual(cluster1_output_record.get(i),clusterMean1) && areEqual(cluster2_output_record.get(i),clusterMean2) && iterationsNo > 1);
 {
    match = true;
    System.out.println("Iteration Number is "+iterationsNo);
    System.out.println("Value of i is "+i);
    System.out.println("Cluster 1 Mean Elements are "+clusterMean1);
    System.out.println("Cluster1_outpt_record is "+cluster1_output_record.get(i));
    System.out.println("Cluster 2 Mean Elements are "+clusterMean2);
    System.out.println("Cluster2_outpt_record is "+cluster2_output_record.get(i));
    System.out.println("Match is "+match);

    }
}

The output is Iteration Number is 2 Value of i is 1

Cluster 1 Mean Elements are [-0.3934348341558447, -0.1360816923944805, -0.2187716886412338, -0.06449051935568194, -0.0010228902759740104, -0.038266953181818164, 0.07982175983766239, 0.010644329474025934, 0.12632030505844166, -0.06995138039935068, -0.09870551273538966, -0.041796415043831185, 0.06937946180032464, -0.01377707767207793, -0.1236233396801949, -0.12645360842045458, -0.3304013244188308, -0.12054819756980542, 0.224283177465909, 0.10693851710064924]
Cluster1_outpt_record is [0.026962710000000008, 0.06232899000000001, -0.36294179, -0.21924168999999996, 0.20080904000000005, -0.05111294000000001, 0.20181597, 0.08179009000000001, -0.32788965999999997, 0.4564200400000001, -0.450951, -0.10415492, 0.11374549999999999, 0.48815618999999993, -0.10235217, 0.11775965, -0.15073421, -0.27097621899999996, 0.012047309999999995, -0.08329656999999999]
Cluster 2 Mean Elements are [0.01719762171005925, -0.20738010449999997, -0.2768948451183433, -0.06780662857396447, 0.087601948091716, 0.042040902568047316, -0.02697104016568048, 0.03858767211005916, 0.16336673178106492, -0.0747453844970414, -0.10509191156804738, -0.09977402825443794, 0.1397649665680474, -0.14198528071005925, -0.10507909705621307, -0.12943119110946746, -0.1155490924585799, -0.13362615999408278, 0.29367396437869797, 0.05711353221301773]
Cluster2_outpt_record is [-0.2508608991546615, -0.16371195734745767, -0.23805550842478812, -0.06403854182319901, 0.028571258098516992, -0.009376577004237283, 0.040292195745762795, 0.01989580426822028, 0.14439635578177967, -0.07724384606567793, -0.09726075418961862, -0.06189477120444918, 0.09411107221292364, -0.06499922312076266, -0.1172088880805086, -0.13010673928177963, -0.25537655401800863, -0.12363725592266969, 0.2513768688336866, 0.0911138412309322]

Match is true

The values of cluster1outputrecord and clusterMean1 are not equal and so the the statements insdie the if loop must not be executed but still the control goes within the if loop... areEqual() is a method and it returns false. I have not included the output of the areEqual()but it shows false

View Answers

January 6, 2012 at 1:22 PM

Please specify the full code. Check your if condition. It seems that problem is there.

Ads









Related Tutorials/Questions & Answers:
Problem with arraylist
Problem with arraylist  I am currently working on a java project and there is an if loop within the for loop.... for(int i = 1;i < iterationsNo.... It seems that problem
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi...everyone Below i have attached my code. This code is working.....but i want some modification in that code such that when i select 'vegetable' or 'fruits
Advertisements
arraylist
arraylist   Using arraylist class , what type of exception are throws, how can write a java programe   An ArrayList can throw... ArraylistException { void buildAlphabet() { ArrayList list = new ArrayList
ArrayList
ArrayList  import java.util.*; class ArrayListDemo2 { public static void main(String args[]) { ArrayList al=new ArrayList(); al.add("one"); al.add("two"); al.add("three"); al.add("four"); for(int i=0;i Expected
arraylist
arraylist  Hi How can we eliminet duplicate element from arraylist? How can we find highest salary from arraylist ? How can we highest key value pair from map? Thanks Kalins Naik   Remove duplicates from Arraylist
arraylist
arraylist  Hi how can we eliminet duplicate element from arraylist in java? how can we achieve data abstrcation and encapulation in java? how many type of modifier are there in java? Thanks kalins anik   Remove
arraylist
arraylist  Hi i have class A , i have added employee name and id in arraylist, then how can i find out all infomation of class A using emplyee... data into an arraylist and display the data of the particular employee according
arraylist
% *(noOfYearService/2). Store each employee information in different arrayList depending on his
arraylist of an arraylist
arraylist of an arraylist  Can anyone suggest me how to use arraylist of an arraylist?? how to put data into it and get data from it???? becoz i want to make rows and column dynamic which can grow as per requirement?????/ plz
comparing arraylist of an multi dimensional arraylist
hence creating total 89 arraylist...please help in solving this problem asap...comparing arraylist of an multi dimensional arraylist  can anyone help me in solving the following issue: actually i have an arraylist called dany
java arraylist
which is having type list1 in the arraylist named list1. the problem here... need to create arraylist whose name is same as type value(e.g : list1,list2... help how to handle this through java arraylist. xml : <?xml version='1.0
arraylist in java
arraylist in java  arraylist in java   Array List Example in java
ArrayList object
ArrayList object  i have am ArrayList object it containg data base records in it, now i want to display this ArrayList object data in my jsp programe, plz help me
ArrayList elements
ArrayList elements  how to print ArrayList elements in reverse order... ArrayListReverse { public static void main(String[] args) { ArrayList list=new ArrayList(); list.add("Innova"); list.add("Alto
accessor arrayList
accessor arrayList  how to use an acccessor to return an arraylist?   public List getProductList(String itemName) { List list=new ArrayList(); //Add your item in the list return list; } You may wish to browse
ArrayList in java
ArrayList in java  sir i have a class Student.it contains id,name,marks of students and a parameteraised constructor.now i created an arraylist... to access marks from arraylist
ArrayList programe
ArrayList programe  How to write a java program to accept an array list of Employee objects. search,delete and modify a particular Employee based on Id Number (like ID,Name&Address
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain... StudentsManager's methods statically. studByYear(year); returns an ArrayList of all
vector and arraylist
vector and arraylist    suppose i have class A { public static arrylist a1(){} class B{ public static vector b1() {} } my question is how to class B method in Class A and how to get vector object values in class A without
arraylist problems?
arraylist problems?   myprogram needs to ask the user for a file name. The file will contain a name on each line. Put each of the names into an ArrayList. After you have put all of the names into the ArrayList search through
ArrayList
arraylist
arrayList
Collection : ArrayList Example
Collection : ArrayList Example This tutorial contains description of Collection ArrayList with example. ArrayList : For ArrayList<E> import... of array creation, which cause problem when you don't know the number
query regarding arraylist
query regarding arraylist  i m using sql server + jsp to develop my program. i have a problem of fetching data from the table in database. i m storing my keys in arraylist, now i want to get data according to that keys. keys
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
ArrayList as an argument to another class
ArrayList as an argument to another class  how do you pass arraylists as arguments to another class, and how does the method/class accept this arraylist for use
Question in Create Arraylist ?
Question in Create Arraylist ?  Good Morning EveryOne I have Q in Java - and if any One have the Answers please tall me ??!! Question...?? to solve the phone directory problem defined above. Thanks a lot
How to Convert ArrayList to Array?
How to Convert ArrayList to Array?  Hi, I am trying to learn to Convert ArrayList to Array. How it is possible? How to Convert ArrayList to Array? Thanks   Hi, To Convert ArrayList to array ArrayList.toArray
Java ArrayList Example
Java ArrayList Example  How can we use array list in java program..."); array.add("Arun"); System.out.println("ArrayList Size...++){ System.out.println("ArrayList Element"+i+" :"+array.get(i
Can ArrayList accept an ImageIcon >>????
Can ArrayList accept an ImageIcon >>????  haw can create ArrayList witch can accept Image ..mean when i use add() method, instead item let me add image to the ArrayList in run time .{should be the program using GUI

Ads