Programming Articles - Page 2463 of 3366

Introduction To Machine Learning using Python

Pavitra
Updated on 28-Aug-2019 13:14:12

361 Views

In this article, we will learn about the basics of machine learning using Python 3.x. Or earlier.First, we need to use existing libraries to set up a machine learning environment>>> pip install numpy >>> pip install scipy >>> pip install matplotlib >>> pip install scikit-learnMachine learning deals with the study of experiences and facts and prediction is given on the bases of intents provided. The larger the database the better the machine learning model is.The flow of Machine LearningCleaning the dataFeeding the datasetTraining the modelTesting the datasetImplementing the modelNow let’s identify which library is used for what purpose −Numpy − adds ... Read More

Differences between Collection and Collections in Java?

Vivek Verma
Updated on 18-Jun-2025 18:25:58

9K+ Views

In Java, Collection and Collections are important components of the Collections Framework. The Collection has various sub-interfaces such as Set, List, and Queue. The Collections provides static methods to perform various operations on collections, such as sorting, searching, and synchronization. Let's learn them one by one with proper definitions, syntax, and a suitable example. The Collection Interface In Java, the Collection is an interface, which is considered the root interface in the collection hierarchy. It represents a group of objects, which are known as its elements. Some collections allow duplicate values and specific orders, whereas some do not allow duplicates ... Read More

How to implement the mouse right-click on each node of JTree in Java?

raja
Updated on 12-Feb-2020 07:26:46

979 Views

A JTree is a subclass of JComponent class that can be used to display the data with the hierarchical properties by adding nodes to nodes and keeps the concept of parent and child node. Each element in the tree becomes a node. The nodes are expandable and collapsible. We can implement the mouse right-click on each node of a JTree using the mouseReleased() method of MouseAdapter class and need to call show() method of JPopupMenu class to show the popup menu on the tree node.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.tree.*; public class JTreeRightClickTest extends JFrame {    public JTreeRightClickTest() {       ... Read More

Can we synchronize a run() method in Java?

Vivek Verma
Updated on 28-Aug-2025 14:46:52

3K+ Views

Yes, we can synchronize a run() method in Java using the synchronized keyword before this method. If this method is synchronized, only one thread can execute this on a given instance of the object at any point in time. Here is a code snippet that shows how to define the run() method as synchronized: @Override synchronized run(){ //code implementation } Here, the @Override annotation specifies that the run() method overrides a method from the Runnable interface, and synchronized is a reserved keyword in Java used to define a method or block as synchronized. Synchronization of a run() ... Read More

How can we remove a selected row from a JTable in Java?

raja
Updated on 02-Jul-2020 13:12:48

8K+ Views

A JTable is a subclass of JComponent class for displaying complex data structures. A JTable component can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces. We can remove a selected row from a JTable using the removeRow() method of the DefaultTableModel class.Syntaxpublic void removeRow(int row)Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class RemoveSelectedRowTest extends JFrame {    private JTable table;    private DefaultTableModel model;    private Object[][] data;    private String[] columnNames;    private JButton button;    public RemoveSelectedRowTest() {       setTitle("RemoveSelectedRow ... Read More

Importance of @Override annotation in Java?

Vivek Verma
Updated on 18-Jun-2025 18:25:31

10K+ Views

What is an Annotation? An annotation is like metadata that provides additional information about the code. It does not affect the code directly but provides the information so that the compiler or runtime environment can use it while executing the code. To define or use any annotation in Java, you need to specify the annotation name starting with the "@" symbol. Here is the syntax to use annotations in Java: @annotation_name Where the @ symbol specifies the annotation, and annotation_name is the name of the annotation. Following is a list of a few important annotations and their usage: ... Read More

Program to reverse an array up to a given position in Python

Hafeezul Kareem
Updated on 27-Aug-2019 13:02:36

864 Views

In this tutorial, we will learn how to reverse an array upto a given position. Let's see the problem statement.We have an array of integers and a number n. Our goal is to reverse the elements of the array from the 0th index to (n-1)th index. For example, Input array = [1, 2, 3, 4, 5, 6, 7, 8, 9] n = 5 Output [5, 4, 3, 2, 1, 6, 7, 8, 9]Procedure to achieve the goal. Initialize an array and a number Loop until n / 2. Swap the (i)th index and (n-i-1)th elements.Print the array you will get the result.Example## initializing array and ... Read More

Python program to remove leading zeros from an IP address

Hafeezul Kareem
Updated on 27-Aug-2019 12:52:36

579 Views

In this tutorial, we are going to write a program which removes leading zeros from the Ip address. Let's see what is exactly is. Let's say we have an IP address 255.001.040.001, then we have to convert it into 255.1.40.1. Follow the below procedure to write the program.Initialize the IP address.Split the IP address with. using the split functionConvert each part of the IP address to int which removes the leading zeros.Join all the parts by converting each piece to str.The result is our final output.Example## initializing IP address ip_address = "255.001.040.001" ## spliting using the split() functions parts = ip_address.split(".") ## ... Read More

Python program to merge two Dictionaries

Hafeezul Kareem
Updated on 27-Aug-2019 12:48:32

677 Views

In this tutorial, we are going to learn how to combine two dictionaries in Python. Let's see some ways to merge two dictionaries.update() methodFirst, we will see the inbuilt method of dictionary update() to merge. The update() method returns None object and combines two dictionaries into one. Let's see the program.Example## initializing the dictionaries fruits = {"apple": 2, "orange" : 3, "tangerine": 5} dry_fruits = {"cashew": 3, "almond": 4, "pistachio": 6} ## updating the fruits dictionary fruits.update(dry_fruits) ## printing the fruits dictionary ## it contains both the key: value pairs print(fruits)If you run the above program, Output{'apple': 2, 'orange': 3, ... Read More

Python program to find all duplicate characters in a string

Sarika Singh
Updated on 26-Aug-2023 08:14:18

40K+ Views

This article teaches you how to write a python program to find all duplicate characters in a string. Characters that repeat themselves within a string are referred to as duplicate characters. When we refer to printing duplicate characters in a string, we mean that we shall print every character, including spaces, that appears more than once in the string in question. Input-Output Scenarios Following is the input-output scenario to find all the duplicate characters in a string − Input: TutorialsPoint Output: t, o, i As we can see, the duplicate characters in the given string "TutorialsPoint" are "t" with ... Read More

Advertisements