Check if a List Contains an Item in Java

Mahesh Parahar
Updated on 10-May-2022 07:30:39

12K+ Views

Elements can be checked from a list using indexOf() or contains() methods.Syntax - indexOf() methodint indexOf(Object o)Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.Parameterso − Element to search for.ReturnsThe index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.ThrowsClassCastException − If the type of the specified element is incompatible with ... Read More

Add Two Lists in Java

Mahesh Parahar
Updated on 10-May-2022 07:24:24

1K+ Views

We can use addAll() methods of List to add two lists.Use addAll() method without index parameterboolean addAll(Collection

Why Are Mountains Triangular in Shape

Prasanna Kotamraju
Updated on 10-May-2022 07:15:35

966 Views

There is this favorite painting of every child, a triangular mountain which has a sun peeping through it, birds flying in the shape of small r, a small hut, and a tree. Well in all this, what amazes many of us is the triangular shape of the mountain. Has it ever bothered you, why mountains are triangular in shape and not circular or rectangular or any shape.Let's try to find an answer to this peculiar and amazing question.The mystery behind the triangular mountain shapeMountains take millennia to be formed and there are various forces like tectonic forces, gravity, frictional force, ... Read More

4 Mobile Computing Trends That Are Hot Right Now

Samual Sam
Updated on 10-May-2022 06:22:53

318 Views

Practically everyone owns a smartphone. The only people still holding out are those who are too old to care and those who don’t want to pay for it. Because of its popularity, mobile computing is now the most rapidly developing technology.Take a look at these four mobile trends that are hot right now.All-in-One Devices Push the Boundaries of SmartphonesPeople want the power of a desktop but the portability of a cellphone. That’s why researchers are working on all-in-one devices that go beyond smartphones. By combining the Internet, GPS, accelerometers, and personal profiles, you get a super mobile device that can ... Read More

Things That Make You Less Productive

Samual Sam
Updated on 09-May-2022 14:05:33

175 Views

To enjoy your family life and to maintain your personality; give time to your family, go out with them for lunch and movie, play with them, do exercise, sleep well to refresh your mood, etc. These all things motivate you towards your family and help you setup the everyday goal.Similarly, to get self-motivation towards your work and to increase productivity, certain things are important, DisorderThere is a direct connection between messed room and messed min; both are co-related with each other. If, your room in messed-up (everything lies on the floor, desk, sofa and everywhere in the room) definitely your ... Read More

Prevent Data Corruption

Samual Sam
Updated on 09-May-2022 13:55:37

2K+ Views

Data corruption is basically a common system errors or bugs, occurs due to loss of data or improper written code. In other word you can say; data corruption is the loss of computer data caused by human, hardware and software. It is basically happens due to changes of the original code. These are some common symptoms of data corruption, Disk hangs or performs slowFile error comes – “invalid file format”File permissions and attributes are changedFiles are renamed with gibberish charactersFiles and folders are displaced or lostComputer regularly crashes and hangs without obvious reasonsDisk actions seem to be very busy even ... Read More

Search a List in Java

Mahesh Parahar
Updated on 09-May-2022 13:54:32

319 Views

Streams can be used to search an item within list.Student student2 = list.stream().filter(s -> {return s.getRollNo() == rollNo);}).findAny().orElse(null);In this example, we're searching a student by roll number.ExampleFollowing is the example showing the usage of streams to search an item in a list −package com.tutorialspoint; import java.util.ArrayList; import java.util.List; public class CollectionsDemo {    public static void main(String[] args) {       List list = new ArrayList();       list.add(new Student(1, "Zara"));       list.add(new Student(2, "Mahnaz"));       list.add(new Student(3, "Ayan"));       System.out.println("List: " + list);       final int rollNoToSearch ... Read More

Oversharing Information on Facebook is Dangerous

Samual Sam
Updated on 09-May-2022 13:51:03

483 Views

Some people are really concern while creating account on Facebook because it not just creates account, also shares your profile, videos, images and posts in front of others. So, surely the question can come in mind that how we are safe after creating account and posting things on Facebook?Facebook is a place where you can spend unlimited time on unlimited sharing, but sometime this sharing becomes too much or harmful. If, you are a Facebook lover and like to share things on Facebook, sometime you also don’t know when you’re sharing becomes oversharing unknowingly that can give very bad impact ... Read More

Tips to Create Shareable Content on Social Media

Samual Sam
Updated on 09-May-2022 13:41:52

194 Views

Maximum people use web to grow their own online business, entertainment, to share confidential and important stuffs through Email or to share their thoughts and ideas through social media sites.Your content is a success key to work on all above platform. Your sharable content should be much and much impressive that can attract millions of people towards you.People who use social networking site, like; Facebook, Twitter, linkedin, etc, should follow the same success key to share their stuffs that can attract maximum to maximum people. When you post something, spend 50% of your time on what to post and 50% ... Read More

Engage a Team to Improve Your Blog Post

Samual Sam
Updated on 09-May-2022 13:26:26

131 Views

A success key of any business or organization is “a team of people”, unity and hard work of them boosts the business and organizations.Similarly, if a blog is a vital part of your business – A team of people play an important role over there. They are answerable for the strategy, content creation, execution, and complete victory of that blog.For a blog post; in a team of people only one or two people involves. Those one or two people partially work for that particular blog post. For every single project, single blog is there that has been managed by those ... Read More

Advertisements