Results 1 to 4 of 4

Thread: Why 'if blocks' not works in Java

  1. #1
    Join Date
    Dec 2011
    Posts
    61

    Why 'if blocks' not works in Java

    Hi friends recently I was trying to create a numeric based program, that would found the greatest number among the 5 number but however I am quite confused about using if blocks. I have seen that whatever I make input for the number, other numbers are also display along with the greatest number. So I just want to know how can I make use of if block to create this program. If you people have any ideas about using if block then please let me know.

  2. #2
    Join Date
    Jun 2011
    Posts
    45

    re: Why 'if blocks' not works in Java

    According to my information this is simple to make the use of if block within the java program, the main thing require using this if block is the perfection and complete concept on this Blocks to make use for java or any other programming language. You can either make use of simple ‘if-else’ block or you can create the nested ‘if-else if- else’ block.

  3. #3
    Join Date
    May 2009
    Posts
    637

    re: Why 'if blocks' not works in Java

    According to my information, the if block not working in following condition
    • if the block don't have the proper opening and closing braces.
    • if the condition that you have specified for the execution of block statement is always returning false value.
    • if the block is not nested properly.
    • if the logical operator is not uses properly according to your program.

  4. #4
    Join Date
    Mar 2010
    Posts
    145

    re: Why 'if blocks' not works in Java

    Try this program may it help you out:
    Code:
    import java.io.*;
    class Abc
    {
    public static void main(String str[])
    {
    int []a= new int[5];
    BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    try
    {
    System.out.pritnln(“Enter your 5 numbers”);
    for(int i=0;i<=4;i++)
    {
    a[i]=Integer.parseInt(br.readLine());
    }
    }
    catch(Exception e)
    {
    System.out.println(“Error found”);
    }
    int max=0;
    max=a[0];
    for(int j=1;j<=4;j++)
    {
    if(max<=a[j])
    {
    max=a[j];
    }
    }
    System.out.println(“The biggest Number is” + max);
    }
    }

Similar Threads

  1. What is JAVA BufferStrategy and how it works
    By LFC18 in forum Software Development
    Replies: 8
    Last Post: 29-04-2014, 10:42 AM
  2. Replies: 3
    Last Post: 25-03-2011, 10:15 AM
  3. How SDA and DDA works in Java Card
    By Rivan in forum Software Development
    Replies: 5
    Last Post: 20-07-2010, 05:13 AM
  4. In Java, What are the Guarded Blocks?
    By warehouse peon in forum Software Development
    Replies: 4
    Last Post: 19-02-2010, 06:21 AM
  5. How to prevent from duplicating catch blocks in java?
    By Kasper in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 08:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,581,628.94941 seconds with 16 queries