Sir, its 2024 .. and i still watch your videos when i have to refer any java concept... You are far better than those bhaiya and didi channels teaching these languages without explaining the core concepts and fleecing students.. Sheer example of OLD IS GOLD..
Hello Kartikeya. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
2020 Update: Its good to understand the general concept, however questions at the end of the video, do not hold water after Java 8. As you can access the local members of the enclosing block from inside the inner class method (if they are final or effectively final). This works in Java 8 and above try yourself. public class Test { int i =10; static int j = 99; public void mi(){ int k =100; final int m = 40; class Inner1{ public void m2(){ System.out.println(i +" " + j +" "+ k+ " "+ m); } } Inner1 i = new Inner1(); i.m2(); } public static void main(String[] args) { Test t = new Test(); t.mi(); } }
Hello Sumit. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Java 8 introduced the concept of effectively final. A variable that is declared and initialized and not being assigned again is considered effectively final. And the compiler allows that code without declaring the variable final.
Hello Rokib Ahmed. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
1:05:00 After Java 8 local variable doesn't not need to declare Final explicitly , but It should be effectively final. Effectively Final means value of local variable should not change inside that method.
To all viewrs of 2020 There is an error at 1.02 with respect to jdk version. Sir is explaining the concept with less then 1.8 verson that's why it will give error .But if u try to compile it in version greater then 8 it will compile. Successfully.
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
The answer is wrong. Still local variable has to be final, but you are not required to explicitly define it. If you are trying to change the value, compiler will inform you an error in your declaration that - 'Variable 'i' accessed from within inner class, needs to be final or effectively final'
in Java8 they made it final internally , so if you declared it as final or not , they are effectively final , thats the reason we can access it in java 8 without marking variable as final
Hello Suresh. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Very nice explanation but after java 1 . 8 version onwards we are not required to declare local variable as final to access them inside the inner class Or inner class method Just keep them effectively final nothing else u can take final also no problem but it's not required Just keep in mind don't modify that variable inside the inner class otherwise u will get compile time error Saying : local variables referenced from an inner class must be final or effectively final
Hello Friend. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Hello utsav. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
In earlier versions of Java, within a non-static nested (inner) class, you couldn't declare static members, methods, or fields directly. However, since Java 8, static methods and fields are allowed within a nested (inner) class if they are declared with the static keyword.
Hello Al Mamun. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Hi durga sir, Regarding Method local inner classes: ------------------------------------------------------------- from 1.8V, we can access the local variable of the method in which inner class has been declared from the inner class. So the concept explained at 1:14:00 was brilliant but how come itz working from 1.8V may i know based on what functionality the local variable is being accepted?
method local inner class can also access "effectively final" local variables. effectively final meaning: 1) variable without final keyword 2) initialized or assigned value only once.
sir, thankyou for lectures, they are very useful. My doubt is :- Method local Inner class purpose is :to reuse the same functionality of method again then why can't method variable be accessed from within the inner class?
Hello Shruthi. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@DurgaSoftwareSolutions Time.Seek( 1:12:30 ) 1.) Reference of inner class also gone when instance method(m1) gone from stack. 2.) when we call m2 method from m1 then m1 is also on stack as well as m2 is on stack, then is it possible to access m1 method variable inside m2 method (when can we access local variables of one method from other method, if both methods are available on stack) ??
Hello Friend. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Dear sir, I have come across you video, i have small doubt regarding below point From method local inner class, we can’t access local variables of the method in which we declare inner class but i am able to access the variable Please find the code below public class DiffeentlevelsOfVariable { int i = 0; static int j = 20; public void m1() { int k = 30; final int m = 40; class Inner { public void m2() { System.out.println("i Value:"+i); System.out.println("j Value:"+j); System.out.println("k Value:"+k); System.out.println("m Value:"+m); } } Inner i = new Inner(); i.m2(); } public static void main(String[] args) { DiffeentlevelsOfVariable obj=new DiffeentlevelsOfVariable(); obj.m1(); } } Output: i Value:0 j Value:20 k Value:30 m Value:40 Successfully i am able to execute the above without having any issues
Hello lakshman. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Sir as we can not access local inner class outside that method so how we can access method m2 of local inner class after completions of method m1 by local inner class object.
Please note 1:02:00 all that is wrong. You can access the variable of the method (x in m1 in this case) from inside m2. If you see clearly he just gave almost the same example 5 min ago in the video. Experts please comment. I would say don't just blindly follow, code yourself and understand. Teachers are humans and can make mistakes. Also I would recommend to watch at 1.75x speed.
Hello Friend. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
Hello Gamer, Thanks for your valuable feedback.It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/U1KKyi You an see more Java videos following link: Java tutorial by durga sir goo.gl/XWb4RL Java 9 by durga sir goo.gl/hXGyBW Java 1.8 Version New Features by Durga sir goo.gl/iHXXYU Adv Java JDBC Tutorial by Durga sir goo.gl/8q16Eo OCJA 1.8 Java SE 8 Programmer - I (1Z0 - 808 ) By Durga sir goo.gl/gC6R7f Core Java by NagoorBabu sir goo.gl/s6Nvj1 Advenced Java by Nagoorbabu sir goo.gl/ZZonzJ CoreJava by Ratan goo.gl/3VM19v Advanced Java jdbc by Ratan goo.gl/Rn2UXr Advjava tutorials - JSP by Ratan goo.gl/Z6ytxm Adv java servlets tutorial by ratan goo.gl/zTwi9y Servlet and JSP Tutorial by anji reddy goo.gl/jZMRUv Advanced Java Jdbc by Anjireddy goo.gl/16CGzX Hibernate byAnjireddy goo.gl/qQojvZ Struts by Anjireddy goo.gl/nE1Eof Spring by Mr.AnjiReddy goo.gl/NfN14R ADV JAVA by Naveen goo.gl/bhSsXF Spring by Mr.Naveen goo.gl/huVwFN Hibernate by Mr. Naveen goo.gl/TY3Wpd Struts by Mr.Naveen goo.gl/Vkmiw7
Regarding to method local inner class- We are able to call static variable of outter class inside the inner class directly and not by class name.Static var. need to be access by class name inside instance area with class name, then how it is possible?
Hello Sir, I just tried 20 - 30 times my code not giving any error for your assertion @1:7:10(can't access local var(x) of method inside method local inner class)...please explain why.
Time: 1:03:00 We are able to access the instance variable declared inside the method public class methodLocalInnerclass { private int data = 30;// instance variable void display() { int u = 10; class Local { void msg() { System.out.println(data); System.out.println(u); } } Local l = new Local(); l.msg(); } public static void main(String args[]) { methodLocalInnerclass obj = new methodLocalInnerclass(); obj.display(); } } Output 30 10 Please advice
I am getting the output as: 10 20 30 40 I don't see any errors as you mentioned in the video can you please elaborate about this example on final and static variable invoking directly. class Random { int i=10; static int j=20; public void m1(){ int k=30; final int m=40; class Inner { public void m2(){ System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(m); }} Inner x= new Inner(); x.m2(); } public static void main(String[] args){ Random y= new Random(); y.m1(); } }
at 1:22:00 we can access instance method using class reference or object reference from static area, right ? so why can't we access i variable from inner class using object reference ?
Sir I declare local variable (i.e inside method) and tried to access from method local class, I am not getting any compile time error. Also I am using JAVA 8 , is there any updation done in JAVA 8 if yes then WHAT? & HOW IT WORKS ?. KINDLY REPLY ASAP
" starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final." So, if you try to change the value "x" and call it you will have the same error. This is called effectively final variable. docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html#accessing-members-of-an-enclosing-class
@Duraga Sir, following code is not giving me any compile time error at line --> System.out.println(k); public class Test { int i =10; static int j = 20; public void m1() { int k= 30 ; final int m = 40; class Inner { public void m2() { System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(m); } } Inner i = new Inner(); i.m2(); } public static void main(String[] args) { Test t = new Test(); t.m1(); } } output - 10 20 30 40 Could you please explain why it is so ?
After Java 8 local variable doesn't not need to declare Final explicitly , but It should be effectively final. Effectively Final means value of local variable should not change inside that method
I understand the only purpose of using MLIC is supporting the nested method requirement still not getting first one purpose which is described in this video .......can anyone explain that to me ?...thanks in advance
Sir, I am facing problem when trying to write following code in Eclipse: Inner.this.x;// CE here C.E. : No enclosing instance of the type Outer.Inner is accessible in scope. I also called m1() method from main() of Outer. But still facing same compile time issue. Sir please help me out. Thanks a lot for this great efforts.
Hello Friend. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Hi Sir, public class Outer { public void m1(){ class inner{ int x=10; public void m2(){ System.out.println(x); } } inner a=new inner(); a.m2(); } public static void main(String[] args) { Outer b=new Outer(); b.m1(); } output :10(No error shown) Reason:
public class Test { int x = 40; public void m() { int x = 67; class inner { int x = 23; public void sum() { System.out.println(x); System.out.println(this .x); System.out.println(Test.this.x); } } inner i = new inner(); i.sum(); } public static void main(String[] args) { Test t = new Test(); t.m(); } } Plz tell me how can I access method variable x
class car{ public void dis(){ int x=6; //that is not final but execute without error class part{ public void m1(){ System.out.println(x); } } part t=new part(); t.m1(); } public static void main(String ar[]){ new car().dis(); } } that program working in jdk(1.8) without error .
At 1:04 there is compiler error which I am not getting, When trying to access local variable of the method in which the inner class is declared, I am not getting any error. My program compiles and runs fine.
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
class Test { public void m1() { int x = 10; class Inner { public void m2() { System.out.println(x); } } new Inner().m2(); } public static void main(String arg[]) { new Test().m1(); } } Sir It execute without final No error show in jdk 1.8
there is no compile-time or run-time error in below code public class LocalMethodInner {
int value =20; static int value1 =30;
public void testMethod(){ int value3 = 40; final int value4 = 50; class Inner{ int value5 = 60; final int value6 =70; public void method(){ System.out.println(value3); }
} Inner inner = new Inner(); inner.method(); } public static void main(String[] args) { LocalMethodInner localMethodInner = new LocalMethodInner(); localMethodInner.testMethod(); } Please suggest why we are able to access value3
I am able to access the x value inside m2 without any compilation issue. Even x is not final variable here(as per your video , it should not accessible ). Is this functionality modified in latest version of java? public class InnerFunction { public void m1(){ int x=10; class A{ void m2(){ System.out.println(x); } } A a = new A(); a.m2(); } public static void main(String...str){ InnerFunction i = new InnerFunction(); i.m1(); } }
starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final." So, if you try to change the value "x" and call it you will have the same error. This is called effectively final variable. docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html#accessing-members-of-an-enclosing-class REPLY 2
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
Hello, can any one explain what is happening in this program ?? Class A { abstract class B{ abstract void m1(); } } Class C extends A.B{ C( A a){ a.super( ); // - - -> (1) } void m1( ){ System.out.println(“Hello”); } public static void main(String[ ] args){ A a = new A( ); C c = new C( a); c.m1( ); } } I understand we can’t directly access inner class without existing outer class object. But what actually is happening at line (1) ?? Why are we passing outer class reference to sub class constructor ??
public class Test { public static Object m1() { final int x = 10; class Inner { public void m1() { System.out.println(x * x); } public String toString() { return "value of x is : " + x; } } Inner i = new Inner(); i.m1(); return i; } public static void m2(Object a) {
Sir, its 2024 .. and i still watch your videos when i have to refer any java concept... You are far better than those bhaiya and didi channels teaching these languages without explaining the core concepts and fleecing students.. Sheer example of OLD IS GOLD..
Hello Kartikeya.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
@@DurgaSoftwareSolutions been a subscriber since channel's inception😃
True Man!!
2020 Update: Its good to understand the general concept, however questions at the end of the video, do not hold water after Java 8. As you can access the local members of the enclosing block from inside the inner class method (if they are final or effectively final). This works in Java 8 and above try yourself.
public class Test {
int i =10;
static int j = 99;
public void mi(){
int k =100;
final int m = 40;
class Inner1{
public void m2(){
System.out.println(i +" " + j +" "+ k+ " "+ m);
}
}
Inner1 i = new Inner1();
i.m2();
}
public static void main(String[] args) {
Test t = new Test();
t.mi();
}
}
correct
Thank you bro
same question came to my mind then I tried to find old java compiler online but to no avail finally confirmed with your comment ty
Thanks bro
you have the gift of maa Saraswathi. you are one of the fabulous teacher I ever seen in my life..
Hello Sumit.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
[1.8V + versions] At 1:04:00 ,we can access local variables but they need to final either explicitly of implicitly(i.e once assigned cannot change)
Java 8 introduced the concept of effectively final. A variable that is declared and initialized and not being assigned again is considered effectively final. And the compiler allows that code without declaring the variable final.
world best teacher is durga sir.. love from bangladesh .
Hello Rokib Ahmed.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
1:05:00
After Java 8 local variable doesn't not need to declare Final explicitly , but It should be effectively final.
Effectively Final means value of local variable should not change inside that method.
To all viewrs of 2020 There is an error at 1.02 with respect to jdk version.
Sir is explaining the concept with less then 1.8 verson that's why it will give error .But if u try to compile it in version greater then 8 it will compile. Successfully.
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
ohh! i was wondering how the same example is working on my pc and not in the video. thanks for clarification.
The answer is wrong. Still local variable has to be final, but you are not required to explicitly define it. If you are trying to change the value, compiler will inform you an error in your declaration that - 'Variable 'i' accessed from within inner class, needs to be final or effectively final'
in Java8 they made it final internally , so if you declared it as final or not , they are effectively final , thats the reason we can access it in java 8 without marking variable as final
thx for sharing
There is a possibility to modify value of variable before inner class declaration.
Again completed watching on sept 02, 2024 at 10.10 PM :)
master of java means Durga Sir only
Hello Suresh.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
1:23:36 static method inside inner class is valied from java 8 onwards. Beginners plz cross check this point.
Very nice explanation but after java 1 . 8 version onwards we are not required to declare local variable as final to access them inside the inner class Or inner class method
Just keep them effectively final nothing else u can take final also no problem but it's not required
Just keep in mind don't modify that variable inside the inner class otherwise u will get compile time error
Saying : local variables referenced from an inner class must be final or effectively final
Your teaching style is amazing
Hello Friend.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
excellent concept explanation 🎉
Hello utsav.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
In earlier versions of Java, within a non-static nested (inner) class, you couldn't declare static members, methods, or fields directly. However, since Java 8, static methods and fields are allowed within a nested (inner) class if they are declared with the static keyword.
Best videos... Covers everything 👌👌👌
Java means Durga Sir. Love you a lot sir
Hello Al Mamun.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
Hi durga sir,
Regarding Method local inner classes:
-------------------------------------------------------------
from 1.8V, we can access the local variable of the method in which inner class has been declared from the inner class. So the concept explained at 1:14:00 was brilliant but how come itz working from 1.8V may i know based on what functionality the local variable is being accepted?
Hello Pranay.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
method local inner class can also access "effectively final" local variables.
effectively final meaning:
1) variable without final keyword
2) initialized or assigned value only once.
i think in latest version of jdk we can make a methods of method local inner class static,it will not throw any error
Hello Friend.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
sir, thankyou for lectures, they are very useful. My doubt is :- Method local Inner class purpose is :to reuse the same functionality of method again then why can't method variable be accessed from within the inner class?
Hello Shruthi.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
Completed watching on 29-05-2024 at 3.30 PM
1:05:00 program of calling local variable in Inner class I didnt got any error. Code worked fine without using final keyword.
@DurgaSoftwareSolutions Time.Seek( 1:12:30 )
1.) Reference of inner class also gone when instance method(m1) gone from stack.
2.) when we call m2 method from m1 then m1 is also on stack as well as m2 is on stack, then is it possible to access m1 method variable inside m2 method (when can we access local variables of one method from other method, if both methods are available on stack) ??
Thanks durga Sir🙏
Compiler will give left on right
Very decently😀😀
Hello Friend.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
I am watching your videos
Impressed a lot..
I want to learn advanced java also
Please help me so,
How to contact
Superb
Dear sir,
I have come across you video, i have small doubt regarding below point
From method local inner class, we can’t access local variables of the method in which we declare inner class
but i am able to access the variable
Please find the code below
public class DiffeentlevelsOfVariable {
int i = 0;
static int j = 20;
public void m1() {
int k = 30;
final int m = 40;
class Inner {
public void m2() {
System.out.println("i Value:"+i);
System.out.println("j Value:"+j);
System.out.println("k Value:"+k);
System.out.println("m Value:"+m);
}
}
Inner i = new Inner();
i.m2();
}
public static void main(String[] args) {
DiffeentlevelsOfVariable obj=new DiffeentlevelsOfVariable();
obj.m1();
}
}
Output:
i Value:0
j Value:20
k Value:30
m Value:40
Successfully i am able to execute the above without having any issues
Yes..we can access..
That is because of you are probably using Java 8 or above version
👏👌🥳
Hello lakshman.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
Sir please update or make a reference in this video From jdk 1.8 version we can access local variable inside inner class
Thanks so much. Durga Sir.
Sir as we can not access local inner class outside that method so how we can access method m2 of local inner class after completions of method m1 by local inner class object.
Hello Pratiksha.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
hey, did you get your answer??
You can, he is just wrong... I have tried it myself. In Java 11.
Please note 1:02:00 all that is wrong. You can access the variable of the method (x in m1 in this case) from inside m2. If you see clearly he just gave almost the same example 5 min ago in the video.
Experts please comment.
I would say don't just blindly follow, code yourself and understand. Teachers are humans and can make mistakes. Also I would recommend to watch at 1.75x speed.
@@dinkarjoshi3309 Hi Dinkar, He might be using old versions of java at that time. It was happening below java 7
Durga sir happy Durga pooja🙏🙏🙏
I am watching your videos
Impressed a lot..
I want to learn advanced java also
Please help me so,
How to contact
Hello Friend.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
just superb
Hello Gamer,
Thanks for your valuable feedback.It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/U1KKyi
You an see more Java videos following link:
Java tutorial by durga sir
goo.gl/XWb4RL
Java 9 by durga sir
goo.gl/hXGyBW
Java 1.8 Version New Features by Durga sir
goo.gl/iHXXYU
Adv Java JDBC Tutorial by Durga sir
goo.gl/8q16Eo
OCJA 1.8 Java SE 8 Programmer - I (1Z0 - 808 ) By Durga sir
goo.gl/gC6R7f
Core Java by NagoorBabu sir
goo.gl/s6Nvj1
Advenced Java by Nagoorbabu sir
goo.gl/ZZonzJ
CoreJava by Ratan
goo.gl/3VM19v
Advanced Java jdbc by Ratan
goo.gl/Rn2UXr
Advjava tutorials - JSP by Ratan
goo.gl/Z6ytxm
Adv java servlets tutorial by ratan
goo.gl/zTwi9y
Servlet and JSP Tutorial by anji reddy
goo.gl/jZMRUv
Advanced Java Jdbc by Anjireddy
goo.gl/16CGzX
Hibernate byAnjireddy
goo.gl/qQojvZ
Struts by Anjireddy
goo.gl/nE1Eof
Spring by Mr.AnjiReddy
goo.gl/NfN14R
ADV JAVA by Naveen
goo.gl/bhSsXF
Spring by Mr.Naveen
goo.gl/huVwFN
Hibernate by Mr. Naveen
goo.gl/TY3Wpd
Struts by Mr.Naveen
goo.gl/Vkmiw7
Sir can u plz let me know from does the execution starts in INNER CLASSES as
for Outer methods it starts from main.
Hello Aravind.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
Thank you so much Durga sir for your response.
Der s a small correction in my comment,its NOT OUTER METHOD BUT ITS an OUTER Class.
Regarding to method local inner class- We are able to call static variable of outter class inside the inner class directly and not by class name.Static var. need to be access by class name inside instance area with class name, then how it is possible?
Hello Ankita.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
Sir plz show graphical representation of inner class
Sir,
In inner class m2 method after printing the values of x and y.. we r creating object of inner class??? (code at 50th minute)
Super sir, thank you
Hello Sir,
I just tried 20 - 30 times my code not giving any error for your assertion @1:7:10(can't access local var(x) of method inside method local inner class)...please explain why.
Time: 1:03:00
We are able to access the instance variable declared inside the method
public class methodLocalInnerclass {
private int data = 30;// instance variable
void display() {
int u = 10;
class Local {
void msg() {
System.out.println(data);
System.out.println(u);
}
}
Local l = new Local();
l.msg();
}
public static void main(String args[]) {
methodLocalInnerclass obj = new methodLocalInnerclass();
obj.display();
}
}
Output
30
10
Please advice
Hello Shubham.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
anna is a big fan of movies
I am getting the output as:
10
20
30
40
I don't see any errors as you mentioned in the video can you please elaborate about this example on final and static variable
invoking directly.
class Random
{
int i=10;
static int j=20;
public void m1(){
int k=30;
final int m=40;
class Inner
{
public void m2(){
System.out.println(i);
System.out.println(j);
System.out.println(k);
System.out.println(m);
}}
Inner x= new Inner();
x.m2();
}
public static void main(String[] args){
Random y= new Random();
y.m1();
}
}
at 1:22:00 we can access instance method using class reference or object reference from static area, right ? so why can't we access i variable from inner class using object reference ?
Hello Gagan.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
Content is amazing but little slow
Thank you sir
Sir I declare local variable (i.e inside method) and tried to access from method local class, I am not getting any compile time error.
Also I am using JAVA 8 , is there any updation done in JAVA 8 if yes then WHAT? & HOW IT WORKS ?.
KINDLY REPLY ASAP
" starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final."
So, if you try to change the value "x" and call it you will have the same error. This is called effectively final variable.
docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html#accessing-members-of-an-enclosing-class
thxz
also I got a new job in Spring MVC + Liferay, is liferay is good
@Duraga Sir, following code is not giving me any compile time error at line --> System.out.println(k);
public class Test {
int i =10;
static int j = 20;
public void m1() {
int k= 30 ;
final int m = 40;
class Inner {
public void m2() {
System.out.println(i);
System.out.println(j);
System.out.println(k);
System.out.println(m);
}
}
Inner i = new Inner();
i.m2();
}
public static void main(String[] args) {
Test t = new Test();
t.m1();
}
}
output - 10
20
30
40
Could you please explain why it is so ?
After Java 8 local variable doesn't not need to declare Final explicitly , but It should be effectively final.
Effectively Final means value of local variable should not change inside that method
I understand the only purpose of using MLIC is supporting the nested method requirement still not getting first one purpose which is described in this video .......can anyone explain that to me ?...thanks in advance
Subarna Sekhar Muni I am asking about what does mean of method specific repeating required functionality .....
Subarna Sekhar Muni Now I got it...thanks for ur reply
Where the inner class object is created
inside the outer class or not
Sir,
I am facing problem when trying to write following code in Eclipse:
Inner.this.x;// CE here
C.E. : No enclosing instance of the type Outer.Inner is accessible in scope.
I also called m1() method from main() of Outer. But still facing same compile time issue. Sir please help me out.
Thanks a lot for this great efforts.
can you please provide complete code? So, as to better understand the problem you are facing
hashmap internal structure means?
Hello Soumya.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
👍👍👍👍👍👍🙏🙏🙏🙏🙏🙏👌👌👌👌👌👌
Hello Friend.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
sir can normal / regular inner class have static access specifier ?? plzzz telll as soo. as possible .
If the class has static access specifier, it is not a normal, member inner class, it is a "nested static" class only.
Hello sir,
I am trying to run this code ( 1: 07: 01 ) but no CE error came,why, any reason for that???
Hello Sanju.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
Hi Sir,
public class Outer {
public void m1(){
class inner{
int x=10;
public void m2(){
System.out.println(x);
}
}
inner a=new inner();
a.m2();
}
public static void main(String[] args) {
Outer b=new Outer();
b.m1();
}
output :10(No error shown)
Reason:
bro you can access instance variable in non static method but m2 method you declare as static then error will occur
public class Test {
int x = 40;
public void m() {
int x = 67;
class inner {
int x = 23;
public void sum() {
System.out.println(x);
System.out.println(this .x);
System.out.println(Test.this.x);
}
}
inner i = new inner();
i.sum();
}
public static void main(String[] args) {
Test t = new Test();
t.m();
}
}
Plz tell me how can I access method variable x
Hello Ganesh.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
class car{
public void dis(){
int x=6; //that is not final but execute without error
class part{
public void m1(){
System.out.println(x);
}
}
part t=new part();
t.m1();
}
public static void main(String ar[]){
new car().dis();
}
}
that program working in jdk(1.8) without error .
yeah i tried this absolutely working fine without final
Sir , can inner class be static in method local inner classes?? Explain with reason.
Banerjee Soumyajit same question ???
Yes
local methods can't have any static anything. Not static nested class, not a static method (methods don't have methods) and not a static variable....
At 1:04 there is compiler error which I am not getting, When trying to access local variable of the method in which the inner class is declared, I am not getting any error. My program compiles and runs fine.
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
class Test {
public void m1() {
int x = 10;
class Inner {
public void m2() {
System.out.println(x);
}
}
new Inner().m2();
}
public static void main(String arg[]) {
new Test().m1();
}
}
Sir It execute without final No error show in jdk 1.8
Same with me also.
there is no compile-time or run-time error in below code public class LocalMethodInner {
int value =20;
static int value1 =30;
public void testMethod(){
int value3 = 40;
final int value4 = 50;
class Inner{
int value5 = 60;
final int value6 =70;
public void method(){
System.out.println(value3);
}
}
Inner inner = new Inner();
inner.method();
}
public static void main(String[] args) {
LocalMethodInner localMethodInner = new LocalMethodInner();
localMethodInner.testMethod();
}
Please suggest why we are able to access value3
Hello Nikhil.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@@DurgaSoftwareSolutions Thanks Durga Sir for reply.....I got answer I am using jdk 1.8 that why I am not getting any error......you are the best..
I am able to access the x value inside m2 without any compilation issue. Even x is not final variable here(as per your video , it should not accessible ). Is this functionality modified in latest version of java?
public class InnerFunction {
public void m1(){
int x=10;
class A{
void m2(){
System.out.println(x);
}
}
A a = new A();
a.m2();
}
public static void main(String...str){
InnerFunction i = new InnerFunction();
i.m1();
}
}
same here
starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final."
So, if you try to change the value "x" and call it you will have the same error. This is called effectively final variable.
docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html#accessing-members-of-an-enclosing-class
REPLY
2
same here using java1.8
@@jonassx100 bro...this effectively final concept is applicable for this method local inner class or... everywhere...
Are these videos (203 videos in core java) outdated or useful
Hello Friend.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
at 1:05:10 u gave an example i executed in jdk10 it is executed it is not give compile time error why sir
this is my mail madhinimd@gmail.com i will send u.java file and output also
Till JDK 7,Local inner class can access only final local variable of the enclosing block. However From JDK 8, it is possible to access the non-final local variable of enclosing block in local inner class.
if both outer and inner class are declared as public then what will b the file name ?
you cannot declare two classes as public.
Compiler will give you Left and Right , if you do so.
It is possible
Hello, can any one explain what is happening in this program ??
Class A {
abstract class B{
abstract void m1();
}
}
Class C extends A.B{
C( A a){
a.super( ); // - - -> (1)
}
void m1( ){
System.out.println(“Hello”);
}
public static void main(String[ ] args){
A a = new A( );
C c = new C( a);
c.m1( );
}
}
I understand we can’t directly access inner class without existing outer class object. But what actually is happening at line (1) ??
Why are we passing outer class reference to sub class constructor ??
Hello Saarya.
Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
public class Test {
public static Object m1() {
final int x = 10;
class Inner {
public void m1() {
System.out.println(x * x);
}
public String toString() {
return "value of x is : " + x;
}
}
Inner i = new Inner();
i.m1();
return i;
}
public static void m2(Object a) {
System.out.println(a.getClass());
System.out.println(a);
}
public static void main(String... a) {
Object obj = m1();
m2(obj);
}
}