Help coderanch get a
new server
by contributing to the fundraiser

Dattatraya Tembare

Greenhorn
+ Follow
since Feb 01, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dattatraya Tembare

I'm sure about second approach; it will work perfectly but not sure about performance point of view which is better.
@Autowired
private A a;

@Autowired
private B b;

For now you can start you work ....

Go though the Spring documentation there are several ways to use it.
12 years ago
Hey .. take it easy.
Get into java & then start reading documentation & SCJP books.
Start with small documents... Type "Introduction to Java + PPT" on Google / or any other search engine. You will get many MS PPTs.
When you get interest in any subject then only you will go in depth of that subject.
Happy learning
12 years ago

Why Spring AOP is preferred over log4j or common-logging?

What are the advantages over these two?

I have seen some discussion & found that mix approach can be used... Can anyone elaborate that where & how to handle such situation?


nagul samy wrote:thanks again.......
Because i was asked in an interview long back...... that is except GC what are the other ways to manage memory in java....???

And what is the difference between System.gc() and finalize() methods.........



See, the purpose of System.gc() and finalize() methods is different.
System.gc() or Runtime.gc - We can request GC to release memory, can't force.
finalize() - will called before garbage collection, means before object get garbage collected.
We can do one more thing we can make objects available for garbage collection.
Ex. A a = new A();
.........
.........
a =null;
Now the object of A is available for garbage collection.

12 years ago

Jeff Verdegan wrote:

Dattatraya Tembare wrote:Yes, it's all about allocation of memory either in Heap or Stack.



No, the reason for not being able to access non-static variables in a static context has nothing to do with heap vs. stack.


And when we call a non-static method it’s part of Stack



The method's variables go on the stack. The executable code for method body itself, like all methods, is on the heap, as part of the class definition.

Now see there are two separate memory locations which are not linked together so we can’t access static variables/methods from non-static methods.



No, that's not right.

The reason we can't refer to non-static members in a static context has nothing to do with where variables are stored. There is no such concept of one area of memory not being able to see the other.

It's much simpler than that. Non-static members require a "this" reference to a "current" object. There is no "this" and no "current object" in a static context. That's simply a natural consequence of what "static" means in the language and it has nothing whatsoever to do with memory layout.



Please explain me what is this here... this is object of existing class & it's on heap & static context is also on heap. So it's having access. When we call methos it creates copy on stack, we are having reference of object (this) so we are able to access the static data which is on Heap.

I think creating an object is all about allocation of memory, how can you separate this?
12 years ago
What kind of projects you are looking for?

Want to outsouce ? Study project? Want to make a product ?

Or any specific?
12 years ago
Yes, it's all about allocation of memory either in Heap or Stack.

When you create static members- variable or methods it goes in Heap only.
Second important thing is , it would not be a part of any instance , it allocates separate memory area in Heap.

When we create a Instance of a class it will create another memory area on heap.

And when we call a non-static method it’s part of Stack because each thread is having separate stack.
Now see there are two separate memory locations which are not linked together so we can’t access static variables/methods from non-static methods.

Non-static methods will be part of same object/memory location so it will allow to access.

Correct me if I'm wrong.
12 years ago
for-each is a Java 5 feature.
Java 5 provided Interface Iterable. Those collections implements/extends this inteface is allowed to use for-each loop.
Maps don't extends Iterable so not allowed to use for-each directly.
All other Collection classes can use it.

About performace can't comment.
12 years ago
Dear All,

Here one important thing has missed, it will clear all doubts.

Heap: is a single area where JVM allocates memory for -Objects, including method code , static variables & instance variables.

Stack: Stack is created for each individual thread, JVM allocates memory for - local variables & arguments (values passed to method variables)

@ interface - all values in interface are constants i.e final static, so it's stored on Heap only.

Hope these will clear the picture.

12 years ago