Learn With Reshu is here to help you all to get new Technological ideas and knowledge. I will try to create blogs on all technical topics and new tricks and tips. please do like share and subscribe Learn with Reshu to encourage me more for creating good help to others.
Thanks,
Best Regards
#learnwithReshu
Advanced Java Programming Advanced Java Programming :- Introduction to advance java As most of us already know that if we want to make normal applications it can be easily built using core Java concepts. But, when it we need to develop web applications, advanced Java fundamentals, like JSP, Servlets, JDBC etc. needed, so to add capabilities and features of the application advance java is essential for developers. Through the motive of this blog is to explain about Advanced Java, I will be giving you a complete insight into the fundamental concepts of Advance Java. Figure - 1.2 If you want to see complete video on this please have a look the video below. Learn with Resh u Advanced Java Programming Course ...
Get link
Facebook
X
Pinterest
Email
Other Apps
Loops in java With Example Code
Get link
Facebook
X
Pinterest
Email
Other Apps
-
LOOPS IN JAVA WITH EXAMPLE CODE
In programming languages, loops are used to execute a set of instructions/functions repeatedly when some conditions become true. There are three types of loops in Java.
for loop
while loop
do-while loop
Java For Loop vs While Loop vs Do While Loop
Java For Loop
The Java for loop is used to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop.
There are three types of for loops in java.
Simple For Loop
For-each or Enhanced For Loop
Labeled For Loop
Example:
01. Simple For Loop
//Java Program to demonstrate the example of for loop
//which prints table of 1
publicclass ForExample {
publicstaticvoid main(String[] args) {
//Code of Java for loop
for(int i=1;i<=10;i++){
System.out.println(i);
}
}
}
Output:
1
2
3
4
5
6
7
8
9
10
02. For-each or Enhanced For Loop
//Java For-each loop example which prints the
//elements of the array
publicclass ForEachExample {
publicstaticvoid main(String[] args) {
//Declaring an array
int arr[]={12,23,44,56,78};
//Printing array using for-each loop
for(int i:arr){
System.out.println(i);
}
}
}
Output:
12
23
44
56
78
03. Labeled For Loop
//A Java program to demonstrate the use of labeled for loop
publicclass LabeledForExample {
publicstaticvoid main(String[] args) {
//Using Label for outer and for loop
aa:
for(int i=1;i<=3;i++){
bb:
for(int j=1;j<=3;j++){
if(i==2&&j==2){
break aa;
}
System.out.println(i+" "+j);
}
}
}
}
Output:
1 1
1 2
1 3
2 1
Java While Loop
The Java while loop is used to iterate a part of the program several times. If the number of iteration is not fixed, it is recommended to use while loop.
publicclass WhileExample {
publicstaticvoid main(String[] args) {
int i=1;
while(i<=10){
System.out.println(i);
i++;
}
}
}
Output:
1
2
3
4
5
6
7
8
9
10
Java do-while Loop
The Java do-while loop is used to iterate a part of the program several times. If the number of iteration is not fixed and you must have to execute the loop at least once, it is recommended to use do-while loop.
The Java do-while loop is executed at least once because condition is checked after loop body.
publicclass DoWhileExample {
publicstaticvoid main(String[] args) {
int i=1;
do{
System.out.println(i);
i++;
}while(i<=10);
}
}
Output:
1
2
3
4
5
6
7
8
9
10
For Complete Explanation in Hindi Please visit My Youtube Channel
Learn Complete OOPS Concepts in one Project In this Page i will give a example Code for covering all oops concepts in only one single project. Class Model Code Example Explanation:- Suppose there is a Organization which has many departments and many Employees Some Employees are Part of Some Departments So In this Code example What i have created is A Organization Class Which is having Many Employees so One Employee Class and Employee is a part of Departments so We have Created one Departments Class Now Organization, Department and Employee has some task to be done so for that i have created Interfaces for each one where i H...
The “Spring Framework” is a large project. Under the Spring Framework label are actually about 20 different Spring projects. Spring MVC, Spring Security, Spring Integration, etc. So, it would be easy to get confused about what “Spring Core” is. The official Spring documentation, contains this image: “Spring Core” is typically used to refer to the functionality of the Core container. Beans, Core, Context, and SpEL. While there are about 30 Spring Framework projects, they all depend on this core container. Its this core functionality that has been around since the beginning of the Spring Framework. The core container, which has the Spring Context, manages dependency injection for us via Inversion of Control is used by all other Spring projects. Spring Boot Application In Hindi Cheers, Learn with Reshu
Running and Building Gradle with Different JDKs - Sip of Java If you are using Gradle as the build tool for your projects and want to work with the latest JDK releases or early-access builds, you might think you are stuck until Gradle supports those versions of the JDK, which might take a few months. However, that’s not the case, and we will explore in this article how to run Gradle with one JDK version while building and testing with a different JDK version. Managing Multiple JDKs When working with multiple JDKs, using a tool like SDKMan or Jenv (for macOS) is highly recommended. These tools enable you to easily manage and switch between your local JDKs. This article assumes that you have multiple JDKs installed on your system: one for running Gradle, and the other for executing the tasks in the build. Be sure that the JDK installed to run Gradle is supported by Gradle. As of the time of this article, the latest Gradle version is 7.6 which supports JDK 19. Configuring the Toolch...
Comments
Post a Comment
Please do not comment any spam link in the comment box