what should the following java code do?
public class foo{ public static void main(String[] args){ boolean mybool=false; assert (mybool==true); } }
Should this give an assertion error? And if not, then why? (I get no errors!)
It must be chosen AssertionErors.
AssertionErors
You need to enable claims if you are using Eclipse. By default, they are disabled.
To do this, add -ea to the JVM arguments.
When starting the program, you need to enable the statements in the Java virtual machine by adding the '-e' command line:
java -ea -jar myprogram.jar
Java . , .
. Apache Commons Lang ( Validator), Spring ( Assert) JUnit4 ( Assert) , VM. Java5, , java assert, , .
, .
( ), , mybool false.
if statements are enabled (jvm -ea argument), the statement will be executed and the side effect of mybool will be set to true.
You can use this to force enable or disable claims. For example, I have a Test in my TestSuites that fails if statements are not included to ensure that statements are always included when tests are run.
Source: https://habr.com/ru/post/1712879/More articles:How to use legacy business logic from a Silverlight application? - architectureSnap to brush color - wpfhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1712876/creating-symbolic-links-to-branches-in-svn&usg=ALkJrhhRQ-6bmGhGp0JIq5PTch4QvsNZYAHow can I use a Django template tag for more than forloop.counter? - djangoкакой лучший шаблон или метод для загрузки статического кеша? - javaDeclare and initialize a struct / class array at the same time - c ++JavaScript variable variable - constant state? - javascriptSQL Server Constraint Validation Request - sql-serverHttpModule and static class, do multiple requests execute the same static data? - c #Find a large cluster of a specific word in a block of text - stringAll Articles