Count Occurrences of Each Character in String in Android

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

542 Views

This example demonstrates How to Count Occurrences of Each Character in String 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 when user click on button, it will check occurrence of letter in string and gives result in textview.Step 3 − Add the following code to ... Read More

What Happens When Buffer is Set to Value None in JSP

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

221 Views

The buffer attribute specifies the buffering characteristics for the server output response object.You may code value of "none" to specify no buffering so that the servlet output is immediately directed to the response object or you may code a maximum buffer size in kilobytes, which directs the servlet to write to the buffer before writing to the response object.To direct the servlet to write the output directly to the response output object, use the following −

Execute DELETE SQL in a JSP

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

872 Views

The tag executes an SQL statement that does not return data; for example, SQL INSERT, UPDATE, or DELETE statements.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultsqlSQL command to execute (should not return a ResultSet)NoBodydataSourceDatabase connection to use (overrides the default)NoDefault databasevarName of the variable to store the count of affected rowsNoNonescopeScope of the variable to store the count of affected rowsNoPageExampleTo start with basic concept, let us create a simple table Employees table in the TEST database and create few records in that table as follows −Step 1Open a Command Prompt and change to the installation directory as follows ... Read More

LocalTime getNano Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

215 Views

The nanosecond of second for a particular LocalTime can be obtained using the getNano() method in the LocalTime class in Java. This method requires no parameters and it returns the nanosecond of second in the range of 0 to 999, 999, 999.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30.53");       System.out.println("The LocalTime is: " + lt);       System.out.println("The nanosecond is: " + lt.getNano());    } }outputThe LocalTime is: 23:15:30.530 The nanosecond is: 530000000Now let us ... Read More

Order By Last 2 Character String in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

2K+ Views

You can use ORDER BY RIGHT() to ORDER BY last 2 character string.The syntax is as followsselect yourColumnName from yourTableName ORDER BY RIGHT(yourColumnName , 2);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table OrderByLast2CharactersDemo    -> (    -> CustomerId varchar(20),    -> CustomerName varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into OrderByLast2CharactersDemo(CustomerId, CustomerName) values('John-98', 'John'); Query OK, 1 row affected (0.20 sec) mysql> insert into OrderByLast2CharactersDemo(CustomerId, CustomerName) values('Carol-91', ... Read More

Get Current Value of a Particular Row from Database Using JDBC

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

1K+ Views

The refreshRow() method of the ResultSet interface refreshes the current row with the most recent value in the database.rs.refreshRow()Assume we have a table named cricketers_data with 7 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1  | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | 2  | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | 3  | Lumara     | Sangakkara | ... Read More

Pass Data Between Fragments in Android

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

4K+ Views

This example demonstrate about How to pass data from one fragment to another fragment 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 fragments to pass the data between two fragments.Step 3 − Add the following code to src /MainActivity.java import android.os.Bundle; import android.support.v4.app.FragmentActivity; public class MainActivity extends FragmentActivity implements ... Read More

Find Keys from Both LinkedHashMap and Store in a List Alternately

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

122 Views

Let us first create a LinkedHashMap with key-value pair −Mapmap1 = new LinkedHashMap(); map1.put("1", "Jim"); map1.put("2", "David"); map1.put("3", "Tom"); map1.put("4", "Sam"); map1.put("5", "Steve");Let us now create another LinkedHashMap with key-value pair −Mapmap2 = new LinkedHashMap(); map2.put("6", "Katie"); map2.put("7", "John"); map2.put("8", "Kane"); map2.put("9", "Chris");Now, create a new List and store the keys in it for both the above Map −Listlist = new ArrayList(); list.addAll(map1.keySet()); list.addAll(map2.keySet());Example Live Demoimport java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class Demo {    public static void main(String[] args) {       Mapmap1 = new LinkedHashMap();       map1.put("1", "Jim");       map1.put("2", "David"); ... Read More

Compare Datetime Column with Only Date in MySQL

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

2K+ Views

To compare DateTime column with only Date, you need to use the Date() method. Following is the syntax. Below, you need to date in the 'yourDateValue':select *from yourTableName where Date(yourColumnName)='yourDateValue';Let us first create a table:mysql> create table DemoTable (    ArrivalTime datetime ); Query OK, 0 rows affected (0.74 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values('2019-01-31 02:34:56'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('2019-04-09 18:20:58'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-05-11 19:45:23'); Query OK, 1 row affected (0.13 ... Read More

Differences Between TreeMap, HashMap, and LinkedHashMap in Java

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

456 Views

Details about TreeMap, HashMap and LinkedHashMap that help to differentiate them are given as follows −TreeMap in JavaA TreeMap in Java is implemented using a Red-Black trees. It has key-value pairs i.e. keys that are associated with the values and the keys are ordered. A TreeMap can only have unique elements and cannot have a null key but have null elements.A program that demonstrates this is given as follows −Example Live Demoimport java.util.*; import java.lang.*; import java.io.*; public class Demo {    public static void main (String[] args) {       TreeMap tMap = new TreeMap();       int[] ... Read More

Advertisements