JavaWith.NextlevelCoders
الذهاب إلى القناة على Telegram
إظهار المزيد
434
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
-230 أيام
أرشيف المشاركات
𝗚𝗶𝘃𝗲 𝘆𝗼𝘂𝗿 𝟮𝟬𝘀𝗲𝗰 𝗮𝗻𝗱 𝗞𝗻𝗼𝘄 𝗮𝗯𝗼𝘂𝘁 𝘁𝗵𝗲 𝗚𝗲𝗻𝗲𝗿𝗶𝗰𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮 ⬇️
https://youtube.com/shorts/OnF01ITm2Zs?si=JFqFWc4ZSO2SSOCE
𝗤. 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗳𝗮𝗹𝗹 𝘁𝗵𝗿𝗼𝘂𝗴𝗵 𝗶𝗻 𝗷𝗮𝘃𝗮 ?
𝗔𝗻𝘀.
In Java, "fall through" refers to the behavior of the switch statement where the control flow moves from one case to the next without interruption if there is no break statement at the end of a case block.
ʜᴇʀᴇ’s aɴ ᴇxᴀᴍᴘʟᴇ ᴛᴏ ɪʟʟᴜsᴛʀᴀᴛᴇ ғᴀʟʟ ᴛʜʀᴏᴜɢʜ ɪɴ a switcʜ sᴛᴀᴛᴇᴍᴇɴᴍ:
𝗖𝗼𝗱𝗲 𝗲𝘅𝗮𝗺𝗽𝗹𝗲
==============================
int day = 3;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
case 4:
System.out.println("Thursday");
case 5:
System.out.println("Friday");
break;
default:
System.out.println("Weekend");
}
==============================
𝗢𝘂𝘁𝗽𝘂𝘁:
Wednesday
Thursday
Friday
==============================
The switch statement evaluates day and finds the case label that matches (case 3).
It executes the statement associated with case 3, which prints "Wednesday".
Because there is no break statement after the case 3 block, the control falls through to case 4 and then case 5, printing "Thursday" and "Friday".
To prevent fall through, you typically include a break statement at the end of each case block, which stops the execution and exits the switch statement. Fall through can be useful when you want multiple cases to execute the same code, but it must be used with caution to avoid unintended behavior.
𝗦𝘂𝗯𝘀𝗰𝗿𝗶𝗯𝗲 𝗢𝘂𝗿 𝗬𝗼𝘂𝗧𝘂𝗯𝗲 𝗖𝗵𝗮𝗻𝗻𝗲𝗹 ⬇️
https://youtube.com/@codingdrawrun?si=io25TymImd89kx7C
𝗠𝘂𝘀𝘁 𝘄𝗮𝘁𝗰𝗵 𝗧𝗵𝗶𝘀 𝗩𝗶𝗱𝗲𝗼
https://youtu.be/DRdgzuDYrAk?si=T_3TT07xrlTtEHYC
| ᴘᴀᴄᴋᴀɢᴇ ɪɴ ᴊᴀᴠᴀ |
𝚃𝚘𝚙𝚒𝚌𝚜 𝙲𝚘𝚟𝚎𝚛 𝚒𝚗 𝚝𝚑𝚒𝚜 𝚟𝚒𝚍𝚎𝚘
===========================
⏺ ᴡʜᴀᴛ ɪs ᴘᴀᴄᴋᴀɢᴇ
⏺ ᴛʏᴘᴇs ᴏғ ᴘᴀᴄᴋᴀɢᴇ (user-def/Built-in)
⏺ sʏɴᴛᴀx ᴏғ ᴘᴀᴄᴋᴀɢᴇ
⏺ ʜᴏᴡ ᴛᴏ ᴄʀᴇᴀᴛᴇ ᴘᴀᴄᴋᴀɢᴇ
⏺ ᴇxᴀᴍᴘʟᴇ ᴏғ ᴘᴀᴄᴋᴀɢᴇ
𝙰𝚗𝚍 𝚍𝚘𝚗'𝚝 𝚏𝚘𝚛𝚐𝚎𝚝 𝚝𝚘 𝚜𝚞𝚋𝚜𝚌𝚛𝚒𝚋𝚎 𝚘𝚞𝚛 𝚈𝚘𝚞𝚃𝚞𝚋𝚎 𝚌𝚑𝚊𝚗𝚗𝚎𝚕 𝚊𝚗𝚍 𝚜𝚑𝚊𝚛𝚎 𝚢𝚘𝚞𝚛 𝚏𝚎𝚎𝚍𝚋𝚊𝚌𝚔 𝚒𝚗 𝚌𝚘𝚖𝚖𝚎𝚗𝚝 𝚋𝚘𝚡.
𝙻𝚎𝚝 𝚖𝚎 𝚔𝚗𝚘𝚠 𝚠𝚑𝚊𝚝 𝚢𝚘𝚞 𝚕𝚒𝚔𝚎𝚍 𝚊𝚗 𝚠𝚑𝚊𝚝 𝚌𝚘𝚞𝚕𝚍 𝚋𝚎 𝚒𝚖𝚙𝚛𝚘𝚟𝚎𝚍.
𝚈𝚘𝚞𝚛 𝚏𝚎𝚎𝚍𝚋𝚊𝚌𝚔 𝚒𝚜 𝚟𝚊𝚕𝚞𝚊𝚋𝚕𝚎 𝚊𝚗𝚍 𝚠𝚒𝚕𝚕 𝚑𝚎𝚕𝚙 𝚖𝚎 𝚖𝚊𝚔𝚎 𝚝𝚑𝚎 𝚌𝚘𝚗𝚝𝚎𝚗𝚝 𝚋𝚎𝚝𝚝𝚎𝚛 𝚏𝚘𝚛 𝚢𝚘𝚞.
https://t.me/+2kahJ-oJjTA5MTBl
Join first 200 members
Front end DEVELOPMENT
Status: Active ✅
https://t.me/+aBQ8zh_Q__40ZTA1
Spring boot Course
Join first 300 members
Status: Active✅
https://t.me/+AK8pJe81RRk5ODBl
Join first 200 members
Front end DEVELOPMENT
Status: Active ✅
Lock Interface In Java
#java #javaprogramming #interface #coding #codinglife #developer #codingmemes
https://www.instagram.com/reel/C7Eqi3ABqIp/?igsh=MWF4aGFsbTQ4eXA5cw==
𝗟𝗼𝗰𝗸 𝗜𝗻𝘁𝗲𝗿𝗳𝗮𝗰𝗲
=====================
The Lock interface in Java is part of the java.util.concurrent.locks package. It provides a more flexible and comprehensive synchronization mechanism than the traditional synchronized keyword.
𝗣𝗮𝗰𝗸𝗮𝗴𝗲
=====================
The Lock interface is located in the java.util.concurrent.locks package.
𝗣𝘂𝗿𝗽𝗼𝘀𝗲
=====================
The Lock interface allows for:
Explicit control over lock acquisition and release.
More advanced operations like timed, interruptible, and try-lock mechanisms.
Providing multiple conditions for a lock.
Introduction
The Lock interface was introduced in Java 5, released in 2004.
𝗪𝗵𝘆 𝗨𝘀𝗲 𝗟𝗼𝗰𝗸?
=====================
Using Lock provides several advantages:
Advanced Locking Mechanisms: Unlike synchronized, which only provides basic mutual exclusion, Lock offers methods like tryLock(), lockInterruptibly(), and timed lock waits.
Flexibility: Lock allows explicit lock management, enabling more complex concurrency control scenarios.
Multiple Conditions: With Lock, you can create multiple Condition objects, allowing threads to wait for different conditions and be notified selectively.
𝗘𝘅𝗮𝗺𝗽𝗹𝗲 𝗠𝗲𝘁𝗵𝗼𝗱𝘀
=====================
lock(): Acquires the lock, blocking the thread if necessary.
lockInterruptibly(): Acquires the lock, but allows the thread to be interrupted while waiting.
tryLock(): Attempts to acquire the lock immediately, returning true if successful.
tryLock(long time, TimeUnit unit): Attempts to acquire the lock within a specified time limit.
unlock(): Releases the lock.
newCondition(): Creates a Condition instance for use with the lock.
These methods offer more control over thread synchronization, making Lock a powerful tool for managing concurrency in complex applications.
𝗝𝗔𝗥 𝗙𝗜𝗟𝗘
==============================
A JAR ("Java archive") file is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution.
JAR files are archive files that include a Java-specific manifest file. They are built on the ZIP format and typically have a .jar file extension.
Filename extension .jar
Developed by : Netscape,Sun Microsystem, Oracle Corporation
Type of formate : data archive , data Compression
Extended from : ZIP
𝗪𝗔𝗥 𝗙𝗜𝗟𝗘
==============================
In software engineering, a WAR file (Web Application Resource[1] or Web application ARchive) is a file used to distribute a collection of JAR-files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application.
Filename extension .war
Developed by : Sun Microsystem
Container for : JSP, java Servlet
Extended from : JAR
𝗘𝗔𝗥 𝗙𝗜𝗟𝗘
==============================
. EAR (Enterprise Application aRchive) is a file format used by Jakarta EE for packaging one or more modules into a single archive so that the deployment of the various modules onto an application server happens simultaneously and coherently. It also contains XML files called deployment descriptors which describe how to deploy the modules.
Filename extension .ear
Developed by : Sun Microsystem
Type of formate : File archive , data Compression
Extended from : JAR
Package in java Part-2
ℙ𝕣𝕒𝕔𝕥𝕚𝕔𝕒𝕝𝕝𝕪 𝕀𝕞𝕡𝕝𝕖𝕞𝕖𝕟𝕥𝕒𝕥𝕚𝕠𝕟
⏺ 𝗕𝗮𝘀𝗶𝗰 𝗞𝗻𝗼𝘄 𝗣𝗮𝗰𝗸𝗮𝗴𝗲
⏺ 𝗠𝗮𝗸𝗲 𝗨𝘀𝗲𝗿 𝗱𝗲𝗳𝗶𝗻𝗲 𝗽𝗮𝗰𝗸𝗮𝗴𝗲 𝗼𝗻 𝗡𝗼𝘁𝗲𝗽𝗮𝗱𝗲
⏺ 𝗞𝗻𝗼𝘄 𝗵𝗶𝗲𝗿𝗮𝗿𝗰𝗵𝘆 𝗼𝗳 𝗽𝗮𝗰𝗸𝗮𝗴𝗲
𝗮𝗻𝗱 𝗰𝗼𝗺𝗺𝗮𝗻𝗱 𝗽𝗿𝗼𝗺𝗽𝘁
⏺ 𝗞𝗻𝗼𝘄 𝗕𝘂𝗶𝗹𝘁 𝗶𝗻 𝗽𝗮𝗰𝗸𝗮𝗴𝗲
𝗪𝗶𝘁𝗵 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹𝗹𝘆 𝗶𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁
⏺ 𝗔𝗹𝘀𝗼 𝗮𝘀𝗸 𝗮𝗻𝗱 𝗴𝗶𝘃𝗲 𝘁𝗮𝘀𝗸𝘀 𝗮𝗻𝗱 𝗹𝗼𝗴𝗶𝗰𝗮𝗹𝗹𝘆 𝗶𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝘀
𝗠𝘂𝘀𝘁 𝘄𝗮𝘁𝗰𝗵 𝘁𝗵𝗶𝘀 𝘃𝗶𝗱𝗲𝗼 𝗮𝗳𝘁𝗲𝗿 𝘄𝗮𝘁𝗰𝗵𝗶𝗻𝗴 𝘁𝗵𝗶𝘀 𝘃𝗶𝗱𝗲𝗼 𝘆𝗼𝘂 𝗸𝗻𝗼𝘄 𝗮𝗹𝗹 𝗮𝗯𝗼𝘂𝘁 𝘁𝗵𝗲 𝗽𝗮𝗰𝗸𝗮𝗴𝗲
𝗛𝗼𝘄 𝗜𝗺𝗽𝗼𝗿𝘁
𝗛𝗼𝘄 𝘄𝗼𝗿𝗸𝘀
𝗬𝗼𝘂𝗧𝘂𝗯𝗲 𝗖𝗵𝗮𝗻𝗻𝗲𝗹 ⬇️
https://youtu.be/DE80VpzONX4?si=5xuikJxBrFp9eRDG
⏺ What is Package
⏺ Types of Package
⏺ Syntax of Package
⏺ How Works
⏺ Example of Package
⏺ Tasks were given in between the lecture
YouTube Channel ⬇️
https://youtu.be/DRdgzuDYrAk?si=MHr7O9f3pYDZr-Qb
# Interfaces In Java #
⏺ Interfaces in Java define a contract for classes to implement.
⏺ They can contain method signatures but not method bodies.
⏺ Multiple interfaces can be implemented by a single class.
⏺Interfaces support multiple inheritance.
⏺ They facilitate loose coupling in software design.
⏺ Default methods were introduced in Java 8 to add method implementations in interfaces.
⏺ Static methods can also be defined in interfaces since Java 8.
⏺ Interfaces are used extensively in Java for achieving abstraction and polymorphism.
