{"id":13646,"date":"2020-03-21T15:37:06","date_gmt":"2020-03-21T22:37:06","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13646"},"modified":"2023-12-01T02:35:23","modified_gmt":"2023-12-01T10:35:23","slug":"java-array-contains","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-array-contains\/","title":{"rendered":"Java Array Contains"},"content":{"rendered":"\n<p>When you\u2019re working with arrays in Java, you may encounter a situation where you want to check whether an array contains a particular value.<\/p>\n\n\n\n<p>For instance, if you are building a program that tracks your bird-watching progress this season, you may want to build a function that allows you to check whether you\u2019ve already seen a particular species of bird.<\/p>\n\n\n\n<p>There are a few approaches that you can use to check whether an array contains a particular value. This tutorial will discuss, with examples, how you can check\u2014using a for-each loop, <code>contains()<\/code>, and <code>stream()<\/code>\u2014if an array in your Java code contains a certain value.<\/p>\n\n\n\n<p>After reading this tutorial, you\u2019ll be an expert at checking whether an array in a Java program contains a particular value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Arrays in Java<\/h2>\n\n\n\n<p>In Java, arrays are containers that hold data of a single type. For example, an array could hold a list of names of 14 bird species you saw in your backyard bird watching this year. Such an array would contain 14 string values.<\/p>\n\n\n\n<p>Arrays are an important data type because they allow developers to store a large number of values in one variable. This is more efficient than storing each of those values as separate variables, and it helps preserve the readability of a program.<\/p>\n\n\n\n<p>Here\u2019s an example of an array in Java: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String[] bagelShops;\nbagelShops = new String[4];<\/pre><\/div>\n\n\n\n<p>In this example, we declared an array\u2014called bagelShops\u2014that stores string values. Then we defined that the bagelShops variable should be capable of storing four strings. Here\u2019s the code we would use to assign four bagel stores to this array: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String[] bagelShops = {\"Absolute Bagels\", \"Bo's Bagels\", \"Brooklyn Bagel and Coffee Company\", \"Forest Hills Bagel\"};<\/pre><\/div>\n\n\n\n<p>But what can we do to check whether an array contains a particular value? For example, what if we wanted to check if Forest Hills Bagel shop was on our list of favorite bagel stores? Let\u2019s delve into a few approaches we can use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using a for-each loop<\/h2>\n\n\n\n<p>for-each loops, also known as <code>enhanced for<\/code> loops, are a form of <code>for loop<\/code> that you can use to loop through all items in an array or collection. For instance, you can use a for-each loop to iterate through a list of coins in an array that stores all the coins in a coin collection.<\/p>\n\n\n\n<p>To check whether an array contains a particular value, we can use a for loop. This for loop will iterate through every item in an array and check whether each item is equal to the item for which we are searching.<\/p>\n\n\n\n<p>Suppose we have a list of our favorite bagel shops in New York City and want to check whether Absolute Bagels is on the list. We can do so using this simple loop:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tpublic static void main(String[] args) {\n\t\tString[] bagelShops = {\"Absolute Bagels\", \"Bo's Bagels\", \"Brooklyn Bagel and Coffee Company\", \"Forest Hills Bagel\"};\n\t\tString shopToFind = \"Absolute Bagels\";\n\t\tboolean found = false;\n\t\tfor (String shop : bagelShops) {\n\t\t\tif (shop == shopToFind) {\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (found) {\n\t\t\tSystem.out.println(\"Absolute Bagels is on your list of favorite bagel stores!\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Absolute Bagels is not on your list of favorite bagel stores.\");\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Absolute Bagels is on your list of favorite bagel stores.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First we declare an array called bagelShops that stores our four favorite bagel shops in NYC.<\/p>\n\n\n\n<p>Then we declare a variable called shopToFind and assign it the value <code>Absolute Bagels<\/code>. This is the value for which we want to search in our bagelShops array. Next, we declare a variable called found, which will be used to track whether <code>Absolute Bagels<\/code> is found in our list.<\/p>\n\n\n\n<p>On the next line, we initialize a for-each loop that loops through every item in the bagelShops list. We then use an <code>if<\/code> statement to check whether each individual shop in our bagelShops list is equal to the value stored in the shopToFind variable.<\/p>\n\n\n\n<p>If the statement evaluates to true, found is set to true, and the for-each loop stops executing because the program runs a <code>break<\/code> statement. If the statement evaluates to false, the code in the if statement does not run.<\/p>\n\n\n\n<p>At the end of our program, if found is equal to true, our code will print <code>Absolute Bagels is on your list of favorite bagel stores!<\/code> to the console; otherwise, our code will print to the console: <code>Absolute Bagels is not on your list of favorite bagel stores.<\/code><\/p>\n\n\n\n<p>We could also use this approach on a list of numbers. So, if we have a list of numbers and want to see whether the list contains a particular number we could use code similar to what we used in our above example. Of course, we would use numbers instead of string values in this case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the contains() method<\/h2>\n\n\n\n<p>You can also check whether an array contains a particular value using the Java <code>contains()<\/code> method. <code>contains()<\/code> accepts one parameter: the value for which you want to search in an array.<\/p>\n\n\n\n<p>The <code>contains()<\/code> method can only be used to check whether an array contains a string value. If you want to search for a number in an array, you may want to use the for-each loop technique instead.<\/p>\n\n\n\n<p>Suppose we have a list of our favorite bands and want to see if the Beatles is in that list. We could use the following code to do so:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tpublic static void main(String[] args) {\n\t\tString[] favoriteBands = {\"Beatles\", \"Revivalists\", \"Jonas Brothers\"};\n\t\tString favoriteToFind = \"Beatles\";\n\t\tboolean found = favoriteBands.contains(favoriteToFind);\n\t\tif (found) {\n\t\t\tSystem.out.println(\"Beatles is on your list of favorite bands!\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Beatles is not on your list of favorite bands.\");\n\t\t}\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Beatles is on your list of favorite bands!<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First we declare an array called favoriteBands which stores a list of the names of our favorite bands. Then we declare a variable called favoriteToFind which stores the name of the band for which we want to search.<\/p>\n\n\n\n<p>On the next line, we use <code>contains()<\/code> to check whether the favoriteBands array contains the value stored in favoriteToFind (which is <code>Beatles<\/code> in this example). We assign the outcome of the <code>contains()<\/code> statement to a boolean called found.<\/p>\n\n\n\n<p>If found is equal to true, our code prints <code>Beatles is on your list of favorite bands!<\/code> to the console; otherwise, our code prints <code>Beatles is not on your list of favorite bands.<\/code> to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the stream() method<\/h2>\n\n\n\n<p>The Java Arrays package contains a number of functions used to work with arrays. One of these functions is <code>stream()<\/code>, which you can use to check if an array contains a particular value. You must use the <code>anyMatch()<\/code> method with the <code>stream()<\/code> function to do so.<\/p>\n\n\n\n<p>Suppose we have a list of our friend Ada\u2019s favorite TV shows, and we want to find out whether <em>Parks and Recreation<\/em> is on her list. We can do so using this code: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Arrays;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tString[] favoriteShows = {\"Billions\", \"Silicon Valley\", \"Superstore\"};\n\t\tString showToFind = \"Parks and Recreation\";\n\t\tboolean found = Arrays.stream(favoriteShows).anyMatch(show -&gt; show.equals(showToFind));\n\t\tif (found) {\n\t\t\tSystem.out.println(\"Parks and Recreation is on Ada's list of favorite TV shows.\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Parks and Recreation is not on Ada's list of favorite TV shows.\");\n\t\t}\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Parks and Recreation is not on Ada's list of favorite TV shows.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First, we import the Java Arrays package. To do so, we use the code: <code>import java.util.Arrays;<\/code>.<\/p>\n\n\n\n<p>Next, we declare an array called favoriteShows. This array stores a list of Ada\u2019s favorite TV shows. Then we declare a variable called showToFind that stores the name of the show we want to find. In this case, we assign the value <code>Parks and Recreation<\/code> to&nbsp; showToFind.<\/p>\n\n\n\n<p>Then, we use the <code>Arrays.stream()<\/code> and <code>anyMatch()<\/code> methods to check whether the value stored in showToFind exists in the favoriteShows array. These methods return a true or false value that is assigned to the found boolean variable.<\/p>\n\n\n\n<p>If the found variable evaluates to true, our program prints <code>Parks and Recreation is on Ada\u2019s list of favorite TV shows.<\/code> to the console. Otherwise, our program prints <code>Parks and Recreation is not on Ada\u2019s list of favorite TV shows.<\/code> to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Checking whether an array contains a particular value is a common operation in Java. The three main approaches for checking whether an array contains a certain value are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>for-each loop<\/li>\n\n\n\n<li>contains()<\/li>\n\n\n\n<li>stream()<\/li>\n<\/ul>\n\n\n\n<p>This tutorial discussed, using examples, how to check whether an array in Java contains a particular value. Now you have the skills you need to check if a Java array contains a certain value like a professional developer!<\/p>\n","protected":false},"excerpt":{"rendered":"When you\u2019re working with arrays in Java, you may encounter a situation where you want to check whether an array contains a particular value. For instance, if you are building a program that tracks your bird-watching progress this season, you may want to build a function that allows you to check whether you\u2019ve already seen&hellip;","protected":false},"author":240,"featured_media":12254,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13646","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Array Contains: The Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-array-contains\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Array Contains\" \/>\n<meta property=\"og:description\" content=\"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-array-contains\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-21T22:37:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:35:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java Array Contains\",\"datePublished\":\"2020-03-21T22:37:06+00:00\",\"dateModified\":\"2023-12-01T10:35:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/\"},\"wordCount\":1151,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/python-string-methods.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/\",\"name\":\"Java Array Contains: The Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/python-string-methods.jpg\",\"datePublished\":\"2020-03-21T22:37:06+00:00\",\"dateModified\":\"2023-12-01T10:35:23+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/python-string-methods.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/python-string-methods.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-array-contains\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Array Contains\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Array Contains: The Complete Guide | Career Karma","description":"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.","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:\/\/careerkarma.com\/blog\/java-array-contains\/","og_locale":"en_US","og_type":"article","og_title":"Java Array Contains","og_description":"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.","og_url":"https:\/\/careerkarma.com\/blog\/java-array-contains\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-21T22:37:06+00:00","article_modified_time":"2023-12-01T10:35:23+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java Array Contains","datePublished":"2020-03-21T22:37:06+00:00","dateModified":"2023-12-01T10:35:23+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/"},"wordCount":1151,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-array-contains\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/","url":"https:\/\/careerkarma.com\/blog\/java-array-contains\/","name":"Java Array Contains: The Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","datePublished":"2020-03-21T22:37:06+00:00","dateModified":"2023-12-01T10:35:23+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Checking whether an array contains a certain value is an important function in Java. On Career Karma, learn three approaches to check if an array in your Java code contains a certain value.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-array-contains\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-array-contains\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java Array Contains"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=13646"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13646\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12254"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}