In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
            
                    
                
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge about "what are the language characteristics of DEFAULT mechanism in ABAP and Java". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
New syntax for ABAP 740:
The code above is equivalent to:
DATA: ls_data LIKE LINE OF it_data.READ TABLE it_data INTO ls_data WITH KEY object_ext = cl_crm_prodil_bo_names=>gc_prod_root.CALL METHOD add_data EXPORTING ir_child_object = ir_root_object is_data = ls_data.
This shows that the new syntax is simpler and can write 3 lines less code. However, there is a flaw in this way. Under the new syntax, if there is no record with cl_crm_prodil_bo_names=>gc_prod_root in the object_ext table in it_data, the program execution will be terminated and the exception CX_SY_ITAB_LINE_NOT_FOUND will be thrown.
ABAP also has a solution for this situation.
Line 17 of the following figure throws an exception, while line 19 does not. It is easy to understand semantically: if there is no record named Spring2 in the inner table lt_data, a structure specified by the developer using the DEFAULT keyword is returned as the default value.
Java 8 has a similar mechanism. To avoid the infamous NullPointerException, Java developers need to check that an object instance is not null before using an object instance method:
if( xx != null ){ xx.doSomething();}
In Java 8, a new utility class Optional is provided in the package java.util, see how it works.
The filter method on line 11 should semantically return null because the string constant I initialized on line 10 is obviously longer than 6. But the object calling the filter method is an Optional object, so the filter method ends up returning an Optional object wrapped around a null. As shown in the debugger below:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





            
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.