« first day (1991 days earlier)      last day (3172 days later) » 
03:00 - 18:0021:00 - 00:00

21:15
Hello
eli
eli
Hey
Singleton obj=Singleton.getInstance();
obj.getInt();
How can u create an object out of a Static method?
oh its because
if(instance==null){
instance=new Singleton();
}
I created a new instance of the object if its not null right
yes it's right but what about this question "How can u create an object out of a Static method?"
it's Singleton you couldn't create more than one
eli
eli
but doesnt static already mean that ?
private static Singleton instance=Volley.newRequestQueue;
les say I did that?
wont instance, be the only object that is shared now?
Y don't have any other way to provide your unique instance instead an entry point which will be a static method
eli
eli
21:26
and in this case u it wouldnt be unique right private static Singleton instance=Volley.newRequestQueue;
what's this Volley.newRequestQueue ?
eli
eli
forget that
lets say it was
private static Singleton instance=1;
why cant I just do that
and then have a method like
public getInstance (){
return instance
instead of
public static Singleton getInstance(){
if(instance==null){
instance=new Singleton();
System.out.println("New Instance");
}
System.out.println("Returned");
return instance;
}
how is that different ?
here you can create more than one instance
your constructor must be private
it's a Singleton pattern you have to follow its rules
eli
eli
ok but its static, so it will be shared by
the entire class no?
it will be shared but can create others instances
eli
eli
21:36
what do u mean
are u saying, that u could make a copy constructor
and copy the static var
to make another instance
is your constructor private or no ?
eli
eli
no
also how do you private static Singleton getInstance(){
if it is private?
if you do this private static Singleton instance=1;
here you didn't make a lazy loading
eli
eli
I am so confused
can u please explain
that means you will create an objet will stay in Heap memory
even if you may won't use it
you gave two pieces of code
the second one is correct okay ?
eli
eli
21:42
which one
public static Singleton getInstance(){
if(instance==null){
instance=new Singleton();
System.out.println("New Instance");
}
System.out.println("Returned");
return instance;
}
the first one:
private static Singleton instance=1;
public getInstance (){
return instance
}
here you cannot access static field from instance method
ah no you can access static field from instance method sorry for that
I am frozen :'(
eli
eli
ok cool thanks
I may go to bed :(
good night
@eli I am not so good in java but you will got response from people here :D
eli
eli
cool thanks man
Bonne nuit
 
2 hours later…
23:59
Can nanohttpd run on windows?
03:00 - 18:0021:00 - 00:00

« first day (1991 days earlier)      last day (3172 days later) »