Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by karthikeya Boyini
Page 4 of 143
CharBuffer hasArray() method in Java
It can be checked if a buffer has the backing of an accessible char array by using the method hasArray() in the class java.nio.CharBuffer. This method returns true if the buffer has the backing of an accessible int array and false otherwise.A program that demonstrates this is given as follows −Exampleimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { CharBuffer buffer = CharBuffer.allocate(5); buffer.put('A'); buffer.put('P'); buffer.put('P'); ...
Read MoreHTML DOM Input FileUpload required Property
The HTML DOM input FileUpload required property returns and modify the value of required attribute of a file upload input button in HTML.SyntaxFollowing is the syntax −1. Returning requiredobject.required2. Modifying requiredobject.required = true|falseExampleLet us see an example of HTML DOM input file upload required property − HTML DOM file upload required Property body{ text-align:center; } .btn{ display:block; margin:1rem auto; background-color:#db133a; color:#fff; border:1px solid #db133a; padding:0.5rem; border-radius:50px; width:20%; ...
Read MoreNavigableSet Class lower() method in Java
The lower() method of NavigableSet returns the greatest element strictly less than the given element i.e. 35 here −lower(35);The following is an example to implement the lower() method in Java −Exampleimport java.util.NavigableSet; import java.util.TreeSet; public class Demo { public static void main(String[] args) { NavigableSet set = new TreeSet(); set.add(10); set.add(25); set.add(40); set.add(55); set.add(70); set.add(85); set.add(100); System.out.println("Returned Value = " + set.lower(35)); } }OutputReturned Value = 25
Read MoreHTML DOM Input Hidden Object
The HTML DOM input hidden object represents the element with type=”hidden” of an HTML document.Create input hidden object −SyntaxFollowing is the syntax −var hiddenInput = document.createElement(“INPUT”); hiddenInput.setAttribute(“type”, ”hidden”);PropertiesFollowing are the properties of HTML DOM input hidden Object −PropertyExplanationformIt returns the cite of the form that contain the hidden input field.nameIt returns and alter the value of name attribute of hidden input field.typeIt returns the value of type attribute of input field.defaultValueIt returns the value of type attribute of input field.defaultValueIt returns and modify the default value of the hidden input field.valueIt returns and modify the value of the value ...
Read MoreRetrieve environment variables with Java Map Collection
First, use the getenv() method to get the environment variables −System.out.println("PATH = " + System.getenv("PATH"));Now, get the key and value. Loop through to get the list of environment variables −Map e = System.getenv(); for (Iterator i = e.entrySet().iterator(); i.hasNext();) { Map.Entry mapEntry = (Map.Entry) i.next(); System.out.println(mapEntry.getKey() + " = " + mapEntry.getValue()); }The following is an example to retrieve environment variables with Map Collection −Exampleimport java.util.Iterator; import java.util.Map; public class Demo { public static void main(String args[]) { System.out.println("PATH = " + System.getenv("PATH")); ...
Read MoreHow to initialize a vector in C++?
Initialization vector can be done in many ways1) Initialize a vector by push_back() methodAlgorithmBegin Declare v of vector type. Call push_back() function to insert values into vector v. Print “Vector elements:”. for (int a : v) print all the elements of variable a. End.Example#include #include using namespace std; int main() { vector v; v.push_back(6); v.push_back(7); v.push_back(10); v.push_back(12); cout
Read MoreCustom ArrayList in Java
A custom ArrayList can have multiple types of data and its attributes in general are based on the user requirements.A program that demonstrates a custom ArrayList is given as follows −Exampleimport java.util.ArrayList; public class CustomArrayList { int n = 5; class Employee { int eno; String name; Employee(int eno, String name) { this.eno = eno; this.name = name; } } public static void main(String args[]) { int eno[] = {101, 102, 103, 104, ...
Read MoreHow to create Java Priority Queue to ignore duplicates?
The simplest way to create a Java Priority Queue to ignore duplicates is to first create a Set implementation −HashSet set = new HashSet (); set.add(100); set.add(150); set.add(250); set.add(300); set.add(250); set.add(500); set.add(600); set.add(500); set.add(900);Now, create Priority Queue and include the set to remove duplicates in the above set −PriorityQueuequeue = new PriorityQueue(set);Exampleimport java.util.HashSet; import java.util.PriorityQueue; public class Demo { public static void main(String[] args) { HashSetset = new HashSet(); set.add(100); set.add(150); set.add(250); set.add(300); set.add(250); set.add(500); ...
Read MoreArrayBlockingQueue Class in Java
A bounded blocking queue that is backed by an array is known as a ArrayBlockingQueue Class in Java. The size of the queue is fixed in the class and it uses FIFO for ordering elements. The ArrayBlockingQueue Class is a member of the Java Collections Framework.A program that demonstrates this is given as follows −Exampleimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) { int n = 10; ArrayBlockingQueue abQueue = new ArrayBlockingQueue(n); abQueue.add(7); abQueue.add(2); abQueue.add(6); abQueue.add(3); ...
Read More