Articles on Trending Technologies

Technical articles with clear explanations and examples

Java Program for focal length of a spherical mirror

AmitDiwan
AmitDiwan
Updated on 23-Dec-2024 358 Views

In this article, we will learn two different approaches to computing the focal length of a spherical mirror using Java. While the second method makes use of Object-Oriented Programming (OOP) concepts for a more generic and flexible approach the first method is a simple functional implementation. Finding Focal Length Spherical mirrors play a vital role in optical systems, from telescopes and microscopes to vehicle rearview mirrors. These mirrors, either concave or convex, focus or diverge light, respectively, based on their geometry. The focal length, a key characteristic of spherical mirrors, determines how the mirror bends light.The focal length of a ...

Read More

Java Regex to extract maximum numeric value from a string

Alshifa Hasnain
Alshifa Hasnain
Updated on 20-Dec-2024 787 Views

In this article, we will learn to extract the maximum numeric value from a string using Java’s regex. While Java provides several ways to handle string manipulation, regular expressions (regex) offer a powerful and efficient tool for such tasks. Problem Statement  The maximum numeric value is extracted from an alphanumeric string. An example of this is given as follows − Input String = abcd657efgh234 Output Maximum numeric value = 657 Using Java Regex and Pattern Class  Java provides the Pattern and Matcher classes to work with regular expressions. The Pattern class compiles a regular expression, and the Matcher class is ...

Read More

How to programmatically navigate using React Router?

Rohit Kumar Dwivedi
Rohit Kumar Dwivedi
Updated on 20-Dec-2024 334 Views

In this article, we will learn how to programmatically navigate using React Router. Programmatic navigation enables changing the URL of an application without reloading the page. We can use several approaches to programmatically navigate in a React application using React Router. Approaches to navigate using React Router To programmatically navigate a React application, we can use several methods based on the version of React Router. In React Router v6, the useNavigate hook is introduced, which is recommended for programmatic navigation. By calling the navigate function returned from useNavigate, we can navigate to other routes. In React Router v5, the ...

Read More

Final vs Immutability in Java

Deepti S
Deepti S
Updated on 19-Dec-2024 2K+ Views

The final keyword in Java may be employed to define a constant value as well as prevent a variable, method, or class from being changed or overridden. On the other side, immutability describes an object's characteristic of keeping a constant state across the course of its existence. The values of an object don't change after it is formed. Variables, methods, and classes are constrained by the "final" keyword, but immutability goes a step further by guaranteeing that the object's whole state is preserved. Let us learn the key differences between final vs immutability in this article. Final in Java ...

Read More

How to Redirect to Another Page in ReactJS?

Rohit Kumar Dwivedi
Rohit Kumar Dwivedi
Updated on 19-Dec-2024 484 Views

Redirecting is one of the vital features in frontend applications like React apps. Moving from one page to another is known as navigation. In React, navigation is important for maintaining a Single Page Application for a better user experience. react-router-dom is a npm package which enables dynamic routing in react application. In this article, we are going to learn how we can redirect from one page to another in ReactJS. Using React Router Dom Navigating to another page can be done efficiently with the help of react-router-dom. It is an npm package responsible for client-side navigation. Using React ...

Read More

How to pass data from child component to its parent in ReactJS?

Rohit Kumar Dwivedi
Rohit Kumar Dwivedi
Updated on 19-Dec-2024 395 Views

Passing data from one component to another is an essential part of building complex React applications. React props and states are fundamental concepts in React. Props stand for properties, which are used for passing data from one component to another, while State is used to manage data within a component. Prerequisites ReactJS Props ReactJS State Passing Data from Child Component to Parent You can easily pass data from a parent component to a child component with the help of props. Passing data from a child component to a ...

Read More

Create an Integer object in Java

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 18-Dec-2024 7K+ Views

To create an Integer object in Java is quite easy. Let us learn about the following two ways for this purpose. Before moving to the coding section, let's briefly discuss the Integer class. The Integer class is a wrapper class in Java, which can be used to encapsulate a primitive int value in an object. Using an Integer Constructor You can create an Integer object using the Integer constructor by passing a primitive int value. In Java, a constructor is a special method whose name is exactly the same as the class name. Example The following example creates an Integer ...

Read More

SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter

SQL
Mohammed Shahnawaz Alam
Mohammed Shahnawaz Alam
Updated on 18-Dec-2024 9K+ Views

When we work with databases, we often need to search for the name of a Person whose name starts with a specific Letter. We can also find the names of persons whose name starts with a specific letter using SQL. This is possible by using the 'LIKE' operator in SQL, it allows us to do pattern matching on a text. Prerequisites: The following are the prerequisites to understand this tutorial - Basic SQL syntax understanding. A database management tool like MySQL, Oracle SQL or SQLite. What is 'LIKE' Operator? The ...

Read More

How to use X-Content-Type-Options to prevent MIME sniffing?

Ashish Jha
Ashish Jha
Updated on 18-Dec-2024 2K+ Views

Data security maintenance plays a critical role in online applications. MIME Sniffing is one such vulnerability, which results from improper installation of security headers and the unauthorised execution of content. A browser will try to get a resource MIME type by content rather than just the Content-Type header. A server sends that header along with a resource. This behaviour can be stopped with the help of the X-Content-Type-Options HTTP header adding to the security fortification. A developer will instruct a browser to firmly follow the defined Content-type and disallow MIME sniffing by this header. The following discussion will provide insights ...

Read More

How to read data from scanner to an array in java?

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 17-Dec-2024 13K+ Views

The Scanner class of the java.util package gives you methods like nextInt(), nextByte(), nextFloat(), etc., to read data from the keyboard. To read an element of an array, use these methods in a 'for' loop. Let us have a brief explanation of the methods of nextInt(), nextByte(), and nextFloat() from the Scanner class in Java. Reading Integer Data Using nextInt() Method The nextInt() method is used to read the next token from the input as an integer. It is commonly used for reading integer values from the keyboard. Example In the following example, we use the nextInt() method of the ...

Read More
Showing 31551–31560 of 61,297 articles
Advertisements