File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Features new in Java 7 and the fly likes two arrays are there if we  are using single for look we can read two indexes one forward direction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "two arrays are there if we  are using single for look we can read two indexes one forward direction " Watch "two arrays are there if we  are using single for look we can read two indexes one forward direction " New topic
Author

two arrays are there if we are using single for look we can read two indexes one forward direction

krishnamurthy durgam
Greenhorn

Joined: Sep 10, 2012
Posts: 13

another one is back ward direction. when two indexes are equal program will be terminated how can achieve this?
I wrote some peace of code in that not enter into if condition it is allways false how can you make it as true?

public class ArraysTest {
public static void main(String args[])

{
int a[]={1,2,3,4,5,6,7,8,9,10};
int b[]={1,2,3,4,5,6,7,8,9,10};
int len=b.length-1;
for(int i=0;i<a.length;i++){
if(i==len){
System.out.println("hello");
break;
}
System.out.println(a[i]);
System.out.println(b[len]);
len--;
}

please help me>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38047
    
  22
Please go back to your code and use the button to add code tags, and change the indentation. You have inconsistent indentation, which means you will not be able to see yourself where all the pairs of {} belong, nor whether they are correctly matched.
Go through the code with a pencil, or add some debugging print statements. Try System.out.printf("a[%d] = %d, len = %d%n", i, a[i], len); at the beginning of your loop. Copy that line by hand, not ctrl-C, because it has &nbsp; characters in. Then you can see what is happening in the loop.
What does len-- at the end do?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: two arrays are there if we are using single for look we can read two indexes one forward direction
 
Similar Threads
Displaying an image from byte[] into JSP
Using enhanced for loop to iterate in reverse order ?
Transfer Multiple File problems via socket
confused abut Enhanced For loop
How to give Servlet response from Tag Handler class?