output occurs but invisible immediately how to rectify this

+1 vote
public class evenodd {

public static void main(String[] args) {

{

int n = 10;

System.out.print("Even Numbers from 1 to "+n+" are: ");

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

   //if number%2 == 0 it means its an even number

   if (i % 2 == 0) {

System.out.print(i + " ");

   }

}

}

   int o = 10;

System.out.print("Odd Numbers from 1 to "+o+" are: ");

for (int a = 1; a <= o; a++) {

   if (a % 2 != 0) {

System.out.print(a + " ");

             }

       }

    }

}
Oct 17, 2019 in Java by BIPLAB
• 130 points
847 views
I tried the code. Works fine.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

+1 vote
1 answer

how to print this statement in java print(' '*(r-x-1)+'*'*(2*x+1)) ( logic used in python .its perfect) but java wrong output came

In ' '*(r-x-1) and '*'*(2*x+1), you used multiplication ...READ MORE

answered Dec 22, 2019 in Java by Utsab Bandyopadhyay
1,141 views
0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

answered Sep 11, 2018 in Java by Sushmita
• 6,920 points
1,434 views
0 votes
1 answer
0 votes
1 answer

org.xml.sax.SAXParseException: How to handle this exception?

This is often caused by a white ...READ MORE

answered Jul 9, 2018 in Java by sharth
• 3,370 points
6,047 views
0 votes
1 answer

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: How to handle this exception?

You have a com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure java.net.ConnectException: ...READ MORE

answered Oct 8, 2018 in Java by Parth
• 4,640 points
2,689 views
0 votes
1 answer

How can I solve this: To prevent a memory leak, the JDBC Driver has been forcibly unregistered

What can you do? Ignore these warnings. Tomcat ...READ MORE

answered Jan 8, 2019 in Java by Daisy
• 8,140 points
31,564 views
0 votes
1 answer

How to solve this error: No Persistence provider for EntityManager named

After <persistence-unit name="agisdb">, define the persi ...READ MORE

answered Jan 8, 2019 in Java by Daisy
• 8,140 points
19,215 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 81,223 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered Aug 20, 2019 in Java by Sirajul
• 59,230 points
2,311 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP