开发者

JAVA- Sandbox & virtual & heap

what is sandbox in java. And whether j2se is java or a tool containing jdk+jre to run java program. In java, why r v not using virtual. Why cant we store stack elements in he开发者_如何学运维ap and viceversa.


It seems like you're asking multiple questions at once, and I'm not entirely sure where one ends and the next one begins. I'm going to try and answer what I think you're asking.

  1. The Java Sandbox
    Java is confined to what it can do with the computer - like keeping a kid playing in a single sandbox, rather than running all over the yard/playground. Exactly how big the 'sandbox' is and what the sandbox contains is not strictly defined, but a Java Application is generally not going to go messing around with many (if any) system resources, and a Java Applet is allowed to do even less.

  2. J2SE: Java or a tool?
    J2SE is Java itself. But it's only one edition of Java: the Standard Edition. The Standard Edition is what you'll see on most end-user machines. Other Java editions are ME (Micro Edition), designed for mobile devices and embedded systems, and EE (Enterprise Edition), designed for server programing.

  3. Why not use virtual?
    I assume you come from another language such as C++ or C#, where you can use the virtual keyword to let subclasses override the superclass method. In Java, there is no virtual, because all public and protected methods can be overridden. In other languages, the difference between using virtual and not means the difference between overriding a method, and shadowing a method. In every case where I've seen it (or done it myself!) method shadowing is a programming error. Because Java does not have virtual, you cannot create method shadowing.

  4. Storing elements in the heap vs. the stack
    Java is a managed language. You don't get to choose where your data is stored in memory, Java does it for you. Java also cleans up your garbage for you. While it's good to understand the stack/heap from a computer science perspective, I think that not having to worry about managing those pointers is very relaxing while writing the actual code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜