Java Coding

Distance between two points in java

2 methods to calculate distance between two points in java with code example. 1- Using formula. 2- Using a Point class objects. Distance between two points using formula We know that the distance between two points (x1,y1) and (x2,y2) on a flat surface is as below. That we’ll use in the java program to find […]

Extract Numbers from String – Java

Java code to extract digits or numbers from a string with logic and explanation. We’ll use 2 methods: (1) using regex expression with replaceAll method of String object, and (2) using loop and ascii values of characters. Extract Numbers from String using regex Logic: Use the regular expression [^0-9] to find non-integer characters in the […]

Scroll to top