This example demonstrate about How to delete element from arraylist for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on delete button to delete the record ... Read More
This example demonstrate about How to delete all elements from linked list for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on ... Read More
This example demonstrate about How to delete all elements from arraylist for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on delete ... Read More
The length property is only applicable to arrays and strings. So when we call the length property on an object we will get undefined.ExampleLive Demo var object = {prop:1, prop:2}; document.write(object.length); OutputundefinedWhereas arrays and strings will display their length when length property is used on them.ExampleLive Demo var string = 'hello'; var array = [1, 2, 3]; var len1 = string.length; var len2 = array.length; document.write(len1); document.write(""); document.write(len2); Output5 3In javascript, we have Object.keys() property, which checks whether there are any properties or not. If we use the length property ... Read More
Java provides three shift operators namely −Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.Example Live Demopublic class Test { public static void main(String args[]) { int a = 60;/* 60 = 0011 1100 */ ... Read More
We can define a property of an object using Dot and Bracket notations. There is also another way in which a property called Object.defineProperty() is used to define a property. It usually takes 3 parameters they are object name, property name, property descriptor.syntaxObject.defineProperty(object name, property name, property descriptor)Lets' define a property with this method.ExampleIn the following example, initially, the object has only one property named 'one'. Later on, another property named 'two' is added. Now when we tried to display all the properties, only the first property was displayed but not the added property as shown in the output.Live Demo ... Read More
The java.lang.StringBuffer class is a thread-safe, mutable sequence of characters. Following are the important points about StringBuffer −A string buffer is like a String, but can be modified.It contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.They are safe for use by multiple threads.Every string buffer has a capacity.Example Live Demoimport java.lang.*; public class StringBufferDemo { public static void main(String[] args) { StringBuffer buff = new StringBuffer("tutorials "); System.out.println("buffer = " + buff); // appends the string argument to ... Read More
We can compare Strings in Java using the compareTo() method and the == operator.comapareTo() method − The compareTo() method compares two strings lexicographically.The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string.The == operator − You can compare two strings using == operator. But, it compares references of the given variables not values.The equals() method of the String class accepts a String as parameter and it compares the current string to the specified object. The result ... Read More
The java.util.StringTokenizer class allows an application to break a string into tokens.This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.Its methods do not distinguish among identifiers, numbers, and quoted strings.This class methods do not even recognize and skip comments.Example Live Demoimport java.util.*; public class StringTokenizerDemo { public static void main(String[] args) { // creating string tokenizer StringTokenizer st = new StringTokenizer("Tutorialspoint is the best site"); // counting tokens System.out.println("Total tokens : " + st.countTokens()); } }OutputTotal tokens : 5
This class is used Join a sequence of characters separating using the delimiter.Examplepublic class StringJoinerSample { public static void main(String[] args){ StringJoiner sj = new StringJoiner(", "); sj.add("Krishna"); sj.add("Raju"); sj.add("Satish"); sj.add("Pruthvi"); System.out.println(sj); } }OutputKrishna, Raju, Satish, Pruthvi
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP