{"id":10410,"date":"2025-08-19T17:40:59","date_gmt":"2025-08-19T17:40:59","guid":{"rendered":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/?p=10410"},"modified":"2025-08-19T17:41:02","modified_gmt":"2025-08-19T17:41:02","slug":"assertion-in-java","status":"publish","type":"post","link":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java","title":{"rendered":"Assertion in Java"},"content":{"rendered":"\n<p>In Java, <strong>assertions<\/strong> are a way to test assumptions about your program during runtime. They are primarily used for debugging purposes and help catch programming errors early. An assertion evaluates a boolean expression, and if the expression evaluates to <code>false<\/code>, the JVM throws an <code>AssertionError<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>assert condition;\n<\/textarea><\/pre><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">assert<\/span><span style=\"color: #D8DEE9FF\"> condition<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>or<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>assert condition : expression;\n<\/textarea><\/pre><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">assert<\/span><span style=\"color: #D8DEE9FF\"> condition <\/span><span style=\"color: #81A1C1\">:<\/span><span style=\"color: #D8DEE9FF\"> expression<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>condition<\/strong> \u2013 a boolean expression that you expect to be <code>true<\/code>.<\/li>\n\n\n\n<li><strong>expression<\/strong> \u2013 an optional message or object that is displayed if the assertion fails.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>public class AssertionExample {\n    public static void main(String[] args) {\n        int age = 15;\n\n        \/\/ Basic assertion\n        assert age > 18 : \"Age must be greater than 18\";\n\n        System.out.println(\"Age is valid: \" + age);\n    }\n}\n<\/textarea><\/pre><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">public<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">AssertionExample<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">public<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">static<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">void<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">main<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #8FBCBB\">String<\/span><span style=\"color: #ECEFF4\">[]<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">args<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">int<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">age<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">15<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">        <\/span><span style=\"color: #616E88\">\/\/ Basic assertion<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">assert<\/span><span style=\"color: #D8DEE9FF\"> age <\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">18<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Age must be greater than 18<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #D8DEE9\">System<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">out<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">println<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Age is valid: <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> age<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The assertion <code>assert age > 18 : \"Age must be greater than 18\";<\/code> checks if <code>age<\/code> is greater than 18.<\/li>\n\n\n\n<li>Since <code>age<\/code> is 15, the assertion fails and throws an <code>AssertionError<\/code> with the message: <code>\"Age must be greater than 18\"<\/code>.<\/li>\n\n\n\n<li>If the condition were <code>true<\/code>, the program would continue normally.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to Enable Assertions<\/strong><\/h3>\n\n\n\n<p>By default, assertions are <strong>disabled<\/strong> in Java. To enable them, use the <code>-ea<\/code> flag when running your program:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>java -ea AssertionExample\n<\/textarea><\/pre><svg xmlns=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/http\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">java <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\">ea <\/span><span style=\"color: #8FBCBB\">AssertionExample<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Points<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Assertions are used for testing assumptions, not for handling runtime errors like exceptions.<\/li>\n\n\n\n<li>They are disabled by default in production, so they shouldn\u2019t replace normal error handling.<\/li>\n\n\n\n<li>Assertions can include a message for better debugging.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In Java, assertions are a way to test assumptions about your program during runtime. They are primarily used for debugging purposes and help catch programming errors early. An assertion evaluates a boolean expression, and if the expression evaluates to false, the JVM throws an AssertionError. Syntax or Example Explanation: How to Enable Assertions By default, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_seopress_analysis_target_kw":"","ocean_post_layout":"right-sidebar","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[172],"tags":[],"class_list":["post-10410","post","type-post","status-publish","format-standard","hentry","category-uncategorized-en","entry","owp-thumbs-layout-horizontal","owp-btn-very-big","owp-tabs-layout-horizontal","has-no-thumbnails","has-product-nav"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Assertion in Java - Custom Software, Infinite Possibilities.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Assertion in Java - Custom Software, Infinite Possibilities.\" \/>\n<meta property=\"og:description\" content=\"In Java, assertions are a way to test assumptions about your program during runtime. They are primarily used for debugging purposes and help catch programming errors early. An assertion evaluates a boolean expression, and if the expression evaluates to false, the JVM throws an AssertionError. Syntax or Example Explanation: How to Enable Assertions By default, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java\" \/>\n<meta property=\"og:site_name\" content=\"Custom Software, Infinite Possibilities.\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-19T17:40:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-19T17:41:02+00:00\" \/>\n<meta name=\"author\" content=\"anis kchaou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"anis kchaou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java\"},\"author\":{\"name\":\"anis kchaou\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#\\\/schema\\\/person\\\/bc01eb392bf5f7248664af5ca7372606\"},\"headline\":\"Assertion in Java\",\"datePublished\":\"2025-08-19T17:40:59+00:00\",\"dateModified\":\"2025-08-19T17:41:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java\"},\"wordCount\":158,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java\",\"url\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java\",\"name\":\"Assertion in Java - Custom Software, Infinite Possibilities.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#website\"},\"datePublished\":\"2025-08-19T17:40:59+00:00\",\"dateModified\":\"2025-08-19T17:41:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/assertion-in-java#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/delta-dev-software.fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Assertion in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#website\",\"url\":\"https:\\\/\\\/delta-dev-software.fr\\\/\",\"name\":\"Delta Dev Software\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/delta-dev-software.fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#organization\",\"name\":\"Delta Dev Software\",\"url\":\"https:\\\/\\\/delta-dev-software.fr\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/delta-dev-software.fr\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/logo-1.png\",\"contentUrl\":\"https:\\\/\\\/delta-dev-software.fr\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/logo-1.png\",\"width\":200,\"height\":200,\"caption\":\"Delta Dev Software\"},\"image\":{\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/delta-dev-software.fr\\\/#\\\/schema\\\/person\\\/bc01eb392bf5f7248664af5ca7372606\",\"name\":\"anis kchaou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g\",\"caption\":\"anis kchaou\"},\"url\":\"https:\\\/\\\/delta-dev-software.fr\\\/author\\\/aniskchaou2022\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Assertion in Java - Custom Software, Infinite Possibilities.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java","og_locale":"en_US","og_type":"article","og_title":"Assertion in Java - Custom Software, Infinite Possibilities.","og_description":"In Java, assertions are a way to test assumptions about your program during runtime. They are primarily used for debugging purposes and help catch programming errors early. An assertion evaluates a boolean expression, and if the expression evaluates to false, the JVM throws an AssertionError. Syntax or Example Explanation: How to Enable Assertions By default, [&hellip;]","og_url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java","og_site_name":"Custom Software, Infinite Possibilities.","article_published_time":"2025-08-19T17:40:59+00:00","article_modified_time":"2025-08-19T17:41:02+00:00","author":"anis kchaou","twitter_card":"summary_large_image","twitter_misc":{"Written by":"anis kchaou","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java#article","isPartOf":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java"},"author":{"name":"anis kchaou","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#\/schema\/person\/bc01eb392bf5f7248664af5ca7372606"},"headline":"Assertion in Java","datePublished":"2025-08-19T17:40:59+00:00","dateModified":"2025-08-19T17:41:02+00:00","mainEntityOfPage":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java"},"wordCount":158,"commentCount":0,"publisher":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java","url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java","name":"Assertion in Java - Custom Software, Infinite Possibilities.","isPartOf":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#website"},"datePublished":"2025-08-19T17:40:59+00:00","dateModified":"2025-08-19T17:41:02+00:00","breadcrumb":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/assertion-in-java#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/"},{"@type":"ListItem","position":2,"name":"Assertion in Java"}]},{"@type":"WebSite","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#website","url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/","name":"Delta Dev Software","description":"","publisher":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#organization","name":"Delta Dev Software","url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#\/schema\/logo\/image\/","url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-content\/uploads\/2021\/04\/logo-1.png","contentUrl":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-content\/uploads\/2021\/04\/logo-1.png","width":200,"height":200,"caption":"Delta Dev Software"},"image":{"@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/#\/schema\/person\/bc01eb392bf5f7248664af5ca7372606","name":"anis kchaou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/secure.gravatar.com\/avatar\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g","url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/secure.gravatar.com\/avatar\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g","contentUrl":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/secure.gravatar.com\/avatar\/6b8ef8891264bd2e394bc2a14877fd3047dbc21b8cc3858f6bd7d6499ecdc54e?s=96&d=mm&r=g","caption":"anis kchaou"},"url":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/author\/aniskchaou2022"}]}},"_links":{"self":[{"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/posts\/10410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/comments?post=10410"}],"version-history":[{"count":1,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/posts\/10410\/revisions"}],"predecessor-version":[{"id":10413,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/posts\/10410\/revisions\/10413"}],"wp:attachment":[{"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/media?parent=10410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/categories?post=10410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/delta-dev-software.fr\/wp-json\/wp\/v2\/tags?post=10410"}],"curies":[{"name":"wp","href":"https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}