Results 1 to 4 of 4
  1. #1
    pierre is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Default probleme with assert statement

    Hi everybody

    I just want to test "assert" statement with a programm like this:
    public static void main(String[] args)
    {
    System.out.println("start");
    assert 1 + 1 == 5;
    System.out.println("end");
    }
    and the result is:
    start
    end

    Why?
    I'm using eclipse 3.5.
    Is existing a mean to disable assertions in eclipe?

    Thanks a lot. Pierre

  2. #2
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    5

    Default

    hi welcome to forum
    Next time please put your code in code tags :)

    Java Code:
    public static void main(String[] args)
    {
    System.out.println("start");
    assert 1 + 1 == 5; 
    System.out.println("end");
    }
    the program prints that because you put start and end in printf statements i dont get your question

  3. #3
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Location
    Texas
    Posts
    238
    Rep Power
    5

    Default

    Assertions are disabled by default (see Java assertions for details).

    In Eclipse, you can enable assertions by using the "-ea" flag. Go to the run arguments and add "-ea" (no quotes) to the VM Arguments. You can do this on a global scope (all projects), for a single project, or even for a single run configuration.
    CodesAway - codesaway.info
    writing tools that make writing code a little easier

  4. #4
    pierre is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Java assert messages lost
    By DavidH in forum Eclipse
    Replies: 0
    Last Post: 08-09-2009, 06:51 PM
  2. If statement, please help??
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 11-23-2008, 02:58 PM
  3. Assert with an informative message
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:04 PM
  4. Assert - not showing any msg on console
    By ravian in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 03:20 PM
  5. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 04:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •