In this section we will see how to convert a number (integer or float or any other numeric type data) to a string.The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() and sprintf(). Here the first argument is the string buffer. where we want to save our data.Input: User will put some numeric value say 42.26 Output: This program will return the string equivalent result of that number like “42.26”AlgorithmStep 1 − ... Read More
Before getting into the example, we should know what ConcurrentLinkedDeque is, it is unbounded deque based on linked nodes. Multiple threads can access deque elements with safety.This example demonstrates about How to use removeLastOccurrence() in android ConcurrentLinkedDequeStep 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 a text view to show ConcurrentLinkedDeque elements.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; ... Read More
To search if strings contain special characters, you can use REGEXP. Following is the syntax −select * from yourTableName where yourColumnName REGEXP '[^a-zA-Z0-9]';Let us first create a table −mysql> create table specialCharactersDemo -> ( -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.58 sec)Insert records in the table using insert command. Following is the query −mysql> insert into specialCharactersDemo values('STU_1234'); Query OK, 1 row affected (0.15 sec) mysql> insert into specialCharactersDemo values('STU567'); Query OK, 1 row affected (0.14 sec) mysql> insert into specialCharactersDemo values('STU#1234'); Query OK, 1 row affected (0.13 sec) mysql> insert into specialCharactersDemo ... Read More
At first, set the Clock:Clock clock = Clock.systemUTC();Now, create LocalDateTime:LocalDateTime dateTime = LocalDateTime.now(clock);Exampleimport java.time.Clock; import java.time.LocalDateTime; public class Demo { public static void main(String[] args) { Clock clock = Clock.systemUTC(); System.out.println("Clock = "+Clock.systemDefaultZone()); LocalDateTime dateTime = LocalDateTime.now(clock); System.out.println("LocalDateTime = "+dateTime); } }OutputClock = SystemClock[Asia/Calcutta] LocalDateTime = 2019-04-19T09:29:50.605820900
To match underscore in a MySQL string, you can use the below syntax −select *from yourTableName where yourColumnName LIKE '%\_%';Let us first create a table −mysql> create table DemoTable ( ClientId varchar(200) ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('CLI_101'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('CLI1110'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('_CLI102'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('CLI103_'); Query OK, 1 row affected (0.12 sec) mysql> insert into ... Read More
A double array for the buffer can be obtained using the method array() in the class java.nio.DoubleBuffer. If the returned array is modified, then the contents of the buffer are also similarly modified and vice versa. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(n); buffer.put(4.5D); buffer.put(1.2D); ... Read More
PPP over ATM (PPPoA) is a data link layer protocol to transmit PPP data over ATM networks, by encapsulating PPP frames in ATM Adaptation Layer 5 (AAL 5) frames.Point − to − Point Protocol (PPP) is a data link layer protocol that is used to transmit data between two directly connected (point-to-point) computers. It is a byte – oriented protocol that is widely used in broadband communications having heavy loads and high speeds. It is also known as RFC 1661.In Asynchronous Transfer Mode (ATM) networks, the ATM Adaptation Layer (AAL) provides facilities for non-ATM based networks to connect to ATM ... Read More
This example demonstrate about How to use unmodifiableSet in Android.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 and record number as Edit text, when user click on save button it will store the data into arraylist. Click on refresh button to get the changes of listview.Step 3 ... Read More
Following are the main components of the ODBC architecture.Application: An application which communicates with the databases using ODBC functions is ODBC application.ODBC driver manager: Whenever an application calls a function of ODBC API to communicate with a database, the driver manager accepts and passes it to ODBC driver and accepts the results from the driver and returns it back to the application.ODBC driver: The ODBC driver accepts the application function calls from the driver manager and connects to the specified DataSource, retrieves the required data and returns it to the driver manager.Data source: A DataSource contains a set of data, ... Read More
This example demonstrate about How to get current internet connection type in android.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 text view to show connection type.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView textView; ... Read More