163 subscribers
3.42K photos
24 videos
39 files
371 links
Link: @java_posts

Contact: java.response.email@gmail.com
Download Telegram
Media is too big
VIEW IN TELEGRAM
Data-Oriented Programming in Java

Data-Oriented Programming with Records, Sealed Classes, Text blocks, and more.

Java has undergone rapid evolution in the past several years. Many of the new features, while surely useful on their own, are designed to work together. See how three of the recent features - records, sealed classes, and pattern matching - work together to enable a data-oriented style of programming, which is a good match for today's cloud applications.
Let's see the palindrome program in java. In this java program, we will get a number variable and check whether number is palindrome or not.

Palindrome Program in Java
Palindrome number in java: A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 171, 48984 are the palindrome numbers. It can also be a string like LOL, MADAM etc.
#Source_code
#12
Checks if a subarray with 0 sum exists or not
Given an integer array, check if it contains a subarray having zero-sum.

Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array.
#Data_structure
We can easily solve this problem in linear time by using hashing. The idea is to use a set to check if a subarray with zero-sum is present in the given array or not. Traverse the array and maintain the sum of elements seen so far. If the sum is seen before (i.e., the sum exists in the set), return true as there exists at least one subarray with zero-sum that ends at the current index; otherwise, insert the sum into the set.
#Data_structure
#Source_code
Media is too big
VIEW IN TELEGRAM
Java Virtual Threads
Concurrent applications, those serving multiple independent application actions simultaneously, are the bread and butter of Java serving-side programming. The thread has been Java's Primary unit of concurrency since its inception and is core to the entire Java platform. However, it can no longer efficiency represent a domain unit of concurrency. As a result, Java has seen a proliferation of libraries and frameworks that offer scalability while abandoning the thread as the unit of software concurrency - and, with it, the support of Java's observability tooling. In this session, learn how Project Loom aims to reinstate the thread as an efficient unit of concurrency by adding a lightweight implementation of threads of the Java platform.
Print Program in Java (Another way)
You can also use a method where number or string is not predefined. Here, user has to put the number or string as input to check if the number/string is palindrome.

Palindrome number algorithm
* Get the number to check for palindrome
* Hold the number in temporary variable
* Reverse the number
* Compare the temporary number with reversed number
* If both numbers are same, print "palindrome number"
* Else Print "not palindrome"
#Source_code
#13
Factorial Program using loop in java
Let's see the factorial Program using loop in Java.
#Source_code
#14
Print all subarrays with 0 sum
Google Translate Icon

Given an integer array, print all subarrays with zero-sum.
Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array.

#Data_Structure
Java
Print all subarrays with 0 sum Google Translate Icon Given an integer array, print all subarrays with zero-sum. Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array. #Data_Structure
Using Brute-Force

A naive solution is to consider all subarrays and find their sum. If the subarray sum is equal to 0, print it. The time complexity of the naive solution is O(n3) as there are n2 subarrays in an array of size n, and it takes O(n) time to find the sum of its elements. We can optimize the method to run in O(n2) time by calculating the subarray sum in constant time.
#Source_code
#Data_structure
Media is too big
VIEW IN TELEGRAM
Java 20 What's new in JDK 20 ?

With Oracle ongoing six-month release cadence and critical path updates, Java continues to thrive due to the core it is built upon: Trust, Innovation, and Predictability. JDK 20, the latest release of the java SE Platform, continues improving on the preview and incubator features unveiled in earlier versions. The new release includes improvement to the Java language and libraries, as well as updates to the Java concurrency model being developed via Project Loom.
Factorial Program using recursion in java
Let's see the factorial program in java using recursion.
#Source_code
#15