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 in Java by BIPLAB
• 130 points
110 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

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,880 points
118 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,350 points
964 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 parth295
• 4,640 points
527 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 in Java by Daisy
• 8,050 points
4,855 views
0 votes
1 answer

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

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

answered Jan 8 in Java by Daisy
• 8,050 points
1,630 views
+5 votes
3 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,380 points

edited Nov 6, 2018 by Omkar 10,285 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 in Java by Sirajul
• 37,930 points
188 views
0 votes
5 answers

How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

answered Jul 12, 2018 in Java by Daisy
• 8,050 points
136 views
+1 vote
2 answers

How to generate random integers within specific range in Java?

You can achieve that concisely in Java: Random ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
64 views