Create Unit Tuple in Java Using with() Method

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

118 Views

Let us create Unit Tuple in Java using with() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Unit Class in Java Tuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Unit; public class Demo {    public static void main(String[] args) {       Unit ... Read More

Concatenate Strings in MySQL

George John
Updated on 30-Jul-2019 22:30:25

178 Views

Yes, you can concatenate strings with || in MySQL with the help of sql_mode. Set the sql_mode to PIPES_AS_CONCAT.The syntax is as followsset sql_mode=PIPES_AS_CONCAT;The following is the syntax to concat with the help of ||.SELECT ‘yourValue' || yourColumName AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table PipeConcatDemo    - > (    - > Name varchar(20)    - > ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into PipeConcatDemo values('Larry'); Query ... Read More

Set Cookies in JSP

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

Setting cookies with JSP involves three steps −Step 1: Creating a Cookie objectYou call the Cookie constructor with a cookie name and a cookie value, both of which are strings.Cookie cookie = new Cookie("key", "value");Keep in mind, neither the name nor the value should contain white space or any of the following characters −[ ] ( ) = , " / ? @ : ;Step 2: Setting the maximum ageYou use setMaxAge to specify how long (in seconds) the cookie should be valid. The following code will set up a cookie for 24 hours.cookie.setMaxAge(60*60*24);Step 3: Sending the Cookie into the ... Read More

Use Replace in Android TextView

Anvi Jain
Updated on 30-Jul-2019 22:30:25

2K+ Views

This example demonstrate about How to use replace () in Android textview.Step 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 button it will take data and replace all a values withStep 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More

The toArray Method of AbstractSequentialList in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:25

92 Views

The toArray() method is inherited from the AbstractCollection() method. It returns an array containing similar elements in this collection.The syntax is as followspublic Object[] toArray()To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList toArray() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();       absSequential.add(210);       absSequential.add(290);       absSequential.add(350);       absSequential.add(490);       absSequential.add(540);       absSequential.add(670);     ... Read More

The toArray Method of Java AbstractCollection Class

Chandu yadav
Updated on 30-Jul-2019 22:30:25

150 Views

The toArray() method of the AbstractCollection class is used to return the elements in this collection. The elements are returned in the form of an array.The syntax is as followspublic Object[] toArray()To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;At first, declare AbstractCollection and add some elementsAbstractCollection absCollection = new ArrayList(); absCollection.add("Laptop"); absCollection.add("Tablet"); absCollection.add("Mobile"); absCollection.add("E-Book Reader");Now, use the toArray() method to return the elements in the form of an arrayObject[] myArr = absCollection.toArray();The following is an example to implement AbstractCollection toArray() method in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo {    public static void main(String[] ... Read More

Convert Date Value to String in JDBC

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

The toString() method of the java.sql.Date class returns the escape format: yyyy-mm-dd of the date represented by the current date object. Using this method you can convert a Date object to a String.Date date = rs.getDate("Dispatch_Date"); date.toString());Assume we have a table named dispatch_data 3 records as shown below:+--------------+------------------+---------------+----------------+ | Product_Name | Name_Of_Customer | Dispatch_Date | Location | +--------------+------------------+---------------+----------------+ | KeyBoard     | Amith            | 1981-12-05    | Hyderabad | | Ear phones   | Sumith           | 1981-04-22   ... Read More

Use NOT and AND Together in MongoDB

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

245 Views

Yes, we can use the NOT and AND together in MongoDB. The syntax is as followsNOT X AND NOT Y = NOT (X AND Y) Let us see the working of above syntax. If both X and Y will be true then last result will be false. If one of the operands gives result false then last result will be true.Following is the query to create a collection with documents> db.NotAndDemo.insertOne({"StudentName":"John", "StudentCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c98746a330fd0aa0d2fe4a8") } > db.NotAndDemo.insertOne({"StudentName":"John", "StudentCountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c987478330fd0aa0d2fe4a9") } > db.NotAndDemo.insertOne({"StudentName":"David", "StudentCountryName":"AUS"}); {   ... Read More

MySQL Query to Select One Specific Row and Another Random Row

George John
Updated on 30-Jul-2019 22:30:25

220 Views

To select one specific row and another random row, you can use ORDER BY and RAND(). Let us first create a sample table:mysql> create table oneSpecificRowAndOtherRandom    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.72 sec)Following is the query to insert some records in the table using insert command:mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Larry'); Query OK, 1 row affected (0.56 sec) mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into oneSpecificRowAndOtherRandom(Name) values('Mike'); Query OK, 1 row affected ... Read More

Check If a Directed Graph is a Tree Using DFS in C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

306 Views

A graph is a tree if it does not contain any cycle. This is a C++ program to check whether a directed graph is tree or not using DFS.AlgorithmBegin function cyclicUtil() :    a) Mark the current node as visited and part of recursion stack    b) Recur for all the vertices adjacent to this vertex.    c) Remove the vertex from recursion stack. function cyclic() :    a) Mark all the vertices as not visited and not part of recursion stack    b) Call the CyclicUtill() function to detect cycle in different trees EndExample#include #include #include using ... Read More

Advertisements