About Question enthuware.ocpjp.v8.2.1565 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Martyjee
Posts: 32
Joined: Tue Oct 06, 2015 9:06 am
Contact:

About Question enthuware.ocpjp.v8.2.1565 :

Post by Martyjee »

The explanation contains the following
The only case where this could be justified is when you are trying to find out whether or not assertions are enabled in your code:    

Code: Select all

boolean enabled = false;
assert enabled == true;
if(enabled)
    System.out.println("Assertions are enabled") 
else
    System.out.println("Assertions are disabled")
If assertions are enabled, the code will figure it out, but it will not do it in a proper way! It will always throw an AssertionError if assertions are enabled and will never reach the if-statement. Line 2 of the code should be modified to:

Code: Select all

assert enabled = true;
(assignment!). In this case 'enabled' will only be set to true if assertions are enabled, because otherwise line 2 will not be executed!

Kind regards,

Martijn

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1565 :

Post by admin »

You are right. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests