Share on Google+Share on Google+

Ravi S.Gohil
Problem with arraylist
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

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.

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
arraylist problem - Java Beginners
arraylist problem  Hello.... I wrote the following code for adding... the string array... But there's a problem with this... import java.util....{ ArrayList al = new ArrayList(); for(int i=0;i<10;i++){ String event
arraylist problem - JSP-Servlet
arraylist problem  hello thanx a lot for ur reply. i m sending u my code once again only in which i m facing the problem. /* * To change...=st1.executeQuery(sql1); ArrayList dstName=new ArrayList
arraylist problem - JSP-Servlet
arraylist problem  in my following code i have used a condition..."); ResultSet rs1=st1.executeQuery(sql1); ArrayList dstName=new ArrayList(); ArrayList Code=new ArrayList(); ArrayList teamLeader
ArrayList problem - JSP-Servlet
ArrayList problem  Hi, How can I add elements of an ArrayList to HTML combobox or list in java? Hi, You can use the following code: Array List..." name="MYLIST"> <% ArrayList a_list = new ArrayList
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
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  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  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  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  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
% *(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
arraylist and vector
arraylist and vector  what is the diff b/w arraylist and vector
Java ArrayList
Java ArrayList   How to declare unique ArrayList
ArrayList and Vector
ArrayList and Vector  hello, Why ArrayList is faster than Vector?   hii, ArrayList is faster than Vector, because ArrayList is not synchronized. Synchronization will reduce the performance of Vector
arraylist in java
arraylist in java  arraylist in java   Array List Example in java
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 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 with session - JSP-Servlet
arraylist with session  hi how can an arraylist stored in session.. and also how will it access?? pls give me the details with sample code..   Hi friend, Code to solve the problem : Thanks
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
Java arraylist of arraylist
Java arrayList can make the use of other arrayList.  In one arrayList other arrayList can be added as the object  It works as two dimension array. Example of Java Arraylist of Arraylist import
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 contains id,name,marks of students and a parameteraised 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
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null