Find the last even in java

In some java interview, most asked question is find the last even of the given array, now we are going to solve this problem.

package one;

public class LastEven {

public static int[] arr = { 28, 3, 4, 6, 10, 11 ,11,23,22,3};

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Last evend=" + lastEven(arr));

public static int lastEven(int[] arr) {
int lE = -1;
for (int x = 0; x < arr.length; x++) {
if (arr[x] % 2 == 0) {
lE = arr[x];
return lE;



Last evend=22


  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

    1. Great Article android based projects

      Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

  2. Advertising is your main tool to have the business ready to go. Actually, everybody is busy in their company marketing over the World Wide Web. Unfortunately, online company is scammed with scammers. On occasion the provider hires you freelance, or occasionally it is a site designer which orders the copy google At an identical time, if you decide on the most suitable company having excellent reviews and reputation, you will enjoy well composed works.

  3. I used to purchase cheap paper service works about java, 'cause I'm not good at it, but with yours site I think I can do my works myself! Thank you very much! Your tutorials are pretty simple, but full and very useful. I love how you explain hard parts. Even I can get it, and it's a deal, coz I'm really bad with programming.