{"id":10,"date":"2021-03-14T22:35:51","date_gmt":"2021-03-14T15:35:51","guid":{"rendered":"https:\/\/www.rnikonorov.ru\/?p=10"},"modified":"2021-03-15T02:00:43","modified_gmt":"2021-03-14T19:00:43","slug":"%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d0%bd%d0%b8%d0%b5-%d1%81%d1%82%d1%80%d0%be%d0%ba%d0%b8-%d1%81-%d1%80%d0%b0%d0%b7%d0%b4%d0%b5%d0%bb%d0%b8%d1%82%d0%b5%d0%bb%d1%8f%d0%bc%d0%b8-%d0%b8%d0%b7-%d1%81%d0%bf","status":"publish","type":"post","link":"https:\/\/www.rnikonorov.ru\/?p=10","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u043c\u0438 &#8212; \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438 \u0438\u0437 Collection&lt;String&gt;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422.\u0435. \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>ArrayList&lt;&gt;(Arrays.asList(\"First string\", \"Second string\", \"Third string\"));<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0410 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>String resultString = \"First string, Second string, Third string\";<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u043e\u0436\u043d\u043e \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 for-\u043e\u043c \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439&nbsp;\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u043e\u0439:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>final List&lt;String&gt; stringListToJoin = new ArrayList&lt;&gt;(stringsToJoin);\nfinal StringBuilder resultString = new StringBuilder();\nfor(int i=0; i &lt; stringsToJoin.size(); i++) {\n    if(i != 0) {\n        resultString.append(delimiter).append(stringListToJoin.get(i));\n    } else {\n        resultString.append(stringListToJoin.get(i));\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u043e \u043f\u043e \u043c\u043d\u0435 \u0442\u0430\u043a \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430 \u043c\u043d\u043e\u0433\u043e\u0432\u0430\u0442\u043e. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 Collection \u043a List \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c .get(int index), \u0430 \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u041d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0436\u0435 \u0431\u044b\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u044d\u0442\u0438\u043c \u043d\u0435 \u043e\u0437\u0430\u0434\u0430\u0447\u0438\u043b\u0441\u044f&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c &#8212; \u043a\u0442\u043e-\u0442\u043e \u043e\u0437\u0430\u0434\u0430\u0447\u0438\u043b\u0441\u044f! \u0418 \u043d\u0435 \u043e\u0434\u0438\u043d!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044f\u043c\u0438 Java 8 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c StringJoiner:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>final StringJoiner joiner = new StringJoiner(delimiter);\nfor(final String element : collectionToJoin) {\n    joiner.add(element);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0434\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u0442 &#8212; \u0432\u0441\u0451 \u043a\u0430\u043a \u044f \u043b\u044e\u0431\u043b\u044e.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0415\u0441\u043b\u0438 Java \u043d\u0435 8-\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c StringUtils.join:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>StringUtils.join(collectionToJoin, delimiter);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0415\u0449\u0451 \u043a\u043e\u0440\u043e\u0447\u0435 \u043a\u043e\u0434, \u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442\u044c \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0443 StringUtils.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u0441\u0435 \u0442\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u043c\u043e\u0451\u043c&nbsp;<a href=\"https:\/\/github.com\/RomanNikonorov\/StingJoinerSamples\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0437\u043d\u0430\u043d\u0438\u0439 &#8212; \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u00a0<a href=\"https:\/\/stackoverflow.com\/questions\/63150\/whats-the-best-way-to-build-a-string-of-delimited-items-in-java\">stackoverflow<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u043c\u0438 &#8212; \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438 \u0438\u0437 Collection&lt;String&gt;. \u0422.\u0435. \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c&nbsp; \u0410 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c&nbsp; \u041c\u043e\u0436\u043d\u043e \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 for-\u043e\u043c \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439&nbsp;\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u043e\u0439: \u041d\u043e \u043f\u043e \u043c\u043d\u0435 \u0442\u0430\u043a \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430 \u043c\u043d\u043e\u0433\u043e\u0432\u0430\u0442\u043e. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 Collection \u043a List \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c .get(int index), \u0430 \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u041d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0436\u0435 \u0431\u044b\u0442\u044c, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_front_end_style_editor":"no","ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","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":"0","ocean_custom_header_template":"0","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":"0","ocean_menu_typo_font_family":"0","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":"0","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":"off","ocean_gallery_id":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-java","entry"],"_links":{"self":[{"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10"}],"version-history":[{"count":2,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":733,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions\/733"}],"wp:attachment":[{"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rnikonorov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}