Filter String Value by Starting Letter

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

3K+ Views

Let’s say the following is our String List −List list = Arrays.asList("Jonny", "David", "Tony", "Jacob", "Smith", "Bravo", "Gayle", "John");Now filter the string value with starting letter −Stream stream = list.stream().filter(name -> name.startsWith("J"));The following is an example to filter string value with starting letter −Exampleimport java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       List list = Arrays.asList("Jonny", "David", "Tony", "Jacob", "Smith",          "Bravo", "Gayle", "John");       System.out.println("List with elements...");       for (String res : list) {          System.out.print(res+" ... Read More

Explain Calendar Module in Python

Sri
Sri
Updated on 30-Jul-2019 22:30:26

379 Views

Python has an inbuilt module and imports all the classes and functions in the module.Example#Write a python program to print month of a calendar? import calendar #prints may month calendar print(calendar.month(2019,5))OutputMay 2019 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Add New Contacts in Android App

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

1K+ Views

This example demonstrate about How to add new contacts in Android App.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             Step 3 − Add the following code to src/MainActivitypackage app.tutorialspoint.com.sample ; import android.app.Activity ; import android.content.Intent ; import android.os.Bundle ; import android.provider.ContactsContract ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.EditText ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle ... Read More

Get Matching Document Inside an Array in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

161 Views

To get the matching document, use $elemMatch. Let us first create a collection with documents −> db.getMatchingDocumentDemo.insertOne(    {       _id :1,       "UserDetails":[          {             "UserName":"John",             "UserAge":23          }       ]    } ); { "acknowledged" : true, "insertedId" : 1 } > db.getMatchingDocumentDemo.insertOne( { _id :2, "UserDetails":[ { "UserName":"Larry", "UserAge":24 } ] } ); { "acknowledged" : true, "insertedId" : 2 }Following is the query to display all documents from a collection with the ... Read More

HTML currentTarget Event Property

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

146 Views

The currentTarget event property in HTML is used to get the element whose event listeners triggered the event.Following is the syntax −event.currentTargetLet us now see an example to implement the currentTarget event property −Example Live Demo Get the element Click on this line to generate an alert box displaying the element whose eventlistener triggered the event.    function myFunction(event) {       alert("Element = "+event.currentTarget.nodeName);    } OutputNow double click on the line as shown in the above screenshot to generate an alert box that would display the element whose event listeners triggered the event −

De-register Driver from Driver Manager's Drivers List using JDBC

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

685 Views

The java.sql.DriverManager class manages JDBC drivers in your application. This class maintains a list of required drivers and load them whenever it is initialized.Therefore, you need to register the driver class before using it. However, you need to do it only once per application.You can register a new Driver class in two ways −Using the registerDriver() method of the DriverManager class. To this method you need to pass the Driver object as a parameter.//Instantiating a driver class Driver driver = new com.mysql.jdbc.Driver(); //Registering the Driver DriverManager.registerDriver(driver);Using the forName() method of the class named Class. To this method you need to ... Read More

Create Arrow Button Positioned North in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

266 Views

To create Arrow Button at position north, use BasicArrowButton:BasicArrowButton arrow = new BasicArrowButton(BasicArrowButton.NORTH);Above, we have set the arrow to NORTH. Now add it to Panel:panel.add(arrow, BorderLayout.NORTH);The following is an example to create Arrow Button positioning North:Exampleimport java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.plaf.basic.BasicArrowButton; public class SwingDemo extends JPanel {    public SwingDemo() {       setLayout(new BorderLayout());       JPanel panel = new JPanel(new BorderLayout());       add(panel, BorderLayout.EAST);       BasicArrowButton arrow = new BasicArrowButton(BasicArrowButton.NORTH);       panel.add(arrow, BorderLayout.NORTH);    }    public static void main(String[] args) {       JFrame frame = ... Read More

Map IntStream to String Object in Java

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

205 Views

To Map IntStream to String object, use mapToObj and within that set the values −.mapToObj(val -> "z" + val)Before that, we used range() on IntStream −IntStream.range(1, 10)The following is an example to map IntStream to String object in Java −Exampleimport java.util.stream.IntStream; public class Demo {    public static void main(String[] args) throws Exception {       IntStream.range(1, 10)       .mapToObj(val -> "z" + val)       .forEach(System.out::println);    } }Outputz1 z2 z3 z4 z5 z6 z7 z8 z9

MySQL Search Results by Month in Format

Smita Kapse
Updated on 30-Jul-2019 22:30:26

75 Views

Use MONTH() and YEAR() for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ShippingDate) values('2019-01-21 10:40:21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ShippingDate) values('2015-07-01 11:15:30'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ShippingDate) values('2012-12-31 10:45:56'); Query OK, 1 row affected (0.14 sec)Display all records from the table ... Read More

Select Specific Text in JTextArea

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

422 Views

Yes, we can do that using built-in methods of JTextArea components. Let’say the following is our JTextArea −JTextArea textArea = new JTextArea("This is a text displayed for our example. We have selected some of the text.");Now, use the methods setSelectionStart() and setSelectionEnd() to select some text in a range −textArea.setSelectionStart(5); textArea.setSelectionEnd(20);The following is an example to select some of the text in a JTextArea −Examplepackage my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo {    SwingDemo() {       JFrame frame = new JFrame("Demo");       JTextArea textArea = new JTextArea("This is a text displayed for our example. ... Read More

Advertisements