Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Can anyone explain this code for me

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can anyone explain this code for me

    Hi I am new to java, I have a bit of code that I would like explaining, stuff like what are the methods what are the variables what are the arrays, and what the code is doing. Any help would be appreciated. Thanks
    public DetectorArray constructArray2(Gate1D timegate, boolean diagonals, boolean allowbad) {
     
    	// Some variables
    	boolean valid,fail,pileup,veto;
    	double sum, max, theta, phi;
    	long t;
     
     
    	DetectorArray result = new DetectorArray();
     
     
    	ArrayList cclist[] = new ArrayList[24];
    	for(int i=0;i<cclist.length;i++){
    	    cclist[i]= new ArrayList<Detector>(0);
    	}
    	for( Detector ge: event.clos.ges){
    	    if(timegate.passes(event.stamp-ge.time)){
    		((ArrayList<Detector>)cclist[ge.number/4]).add(ge);
    	    }
    	}
     
     
    	for(int i=0;i<cclist.length;i++){
     
    	    switch (cclist[i].size()){
    	    case 1:
    		// Single detector hit case
    		// Pull out the hit
    		Detector ge = ((ArrayList<Detector>)cclist[i]).get(0);
    		// Create and store the new detector object
    		if((!ge.fail && !ge.piledup && !ge.vetoed ) || allowbad)
    		    result.ges.add(new Detector(i+16,(i/12)+4,ge.theta,ge.phi,ge.e,ge.time,1,ge.valid,ge.fail,ge.piledup,ge.vetoed));
    		break;
    		}
    		}
     
    			for( Detector ge: event.ph1s.ges){
    			    if(timegate.passes(event.stamp-ge.time))result.ges.add(ge);
    			}
    			return result;


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Can anyone explain this code for me

    I'd suggest looking through this tutorial on the Java language by Sun: Getting Started, and Learning the Java Language.

Similar Threads

  1. Help me this code! Someone please explain strings!
    By helpthiscode in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 16th, 2009, 03:13 AM
  2. can anyone explain this?
    By chronoz13 in forum Java Theory & Questions
    Replies: 4
    Last Post: October 12th, 2009, 02:51 AM

Tags for this Thread