{"id":490,"date":"2018-02-21T02:03:43","date_gmt":"2018-02-21T02:03:43","guid":{"rendered":"http:\/\/kaizen-koka.com\/?p=490"},"modified":"2018-02-21T02:04:32","modified_gmt":"2018-02-21T02:04:32","slug":"core-java-assignment-10","status":"publish","type":"post","link":"https:\/\/kaizen-koka.com\/?p=490","title":{"rendered":"Core Java Assignment 10"},"content":{"rendered":"<p>\n\t1. Create a list with elements &#8211; &quot;d2&quot;, &quot;a2&quot;, &quot;b1&quot;, &quot;b3&quot;, &quot;c&quot; and filter the elements that start with &quot;a&quot; and print the element in uppercase.\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t2. Create a Person class with fields name and age.\n<\/p>\n<p>\n\t&nbsp; &nbsp; Create a list which contains Person objects.\n<\/p>\n<p>\n\t&nbsp; &nbsp; List&lt;Person&gt; persons =\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Arrays.asList(\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Person(&quot;Max&quot;, 18),\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Person(&quot;Peter&quot;, 23),\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Person(&quot;Pamela&quot;, 23),\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Person(&quot;David&quot;, 12));\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t&nbsp; &nbsp; 1. Print the list of person names (print as a list) that start with &quot;P&quot;.\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; Answer &#8211; [Peter, Pamela]\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; Hint &#8211; Use .collect(Collectors.toList()) to print as a list\n<\/p>\n<p>\n\t&nbsp; &nbsp; 2.&nbsp; Sort the list of persons by age and print the person names as a list.\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; Answer &#8211; [David, Max, Peter, Pamela]\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t3. Print the numbers greater than 5 from the below list.\n<\/p>\n<p>\n\t&nbsp; &nbsp; List&lt;Integer&gt; numbers = Arrays.asList(1, 5, 7, 3, 8, 10, 48, 67, 2, 23, 56, 11, 4, 100);\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t&nbsp; &nbsp; Answer &#8211; 7, 8, 10, 48, 67, 23, 5, 11, 100\n<\/p>\n<p>\n\t&nbsp; &nbsp; Hint &#8211; Use Streams and Lambdas expression to filer and sort.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Create a list with elements &#8211; &quot;d2&quot;, &quot;a2&quot;, &quot;b1&quot;, &quot;b3&quot;, &quot;c&quot; and filter the elements that start with &quot;a&quot; and print the element in uppercase. &nbsp; 2. Create a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[8,3],"tags":[],"class_list":["post-490","post","type-post","status-publish","format-standard","hentry","category-assignments","category-java"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p70lnf-7U","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=490"}],"version-history":[{"count":1,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/490\/revisions"}],"predecessor-version":[{"id":491,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/490\/revisions\/491"}],"wp:attachment":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}