Home » Java » Core Java (page 255)

Core Java

C++ or Java, which is faster for high frequency trading?

Overview There are conflicting views as to what is the best solution for high frequency trading. Part of the problem is that what is high frequency trading varies more than you might expect, another part is what is meant by faster. My View If you have a typical Java programmer and typical C++ programmer, each with a few years experience ...

Read More »

Java and Memory Leaks

Overview The term “memory leak” is used in Java in a manner which is different to how it is used in other languages. What does a “memory leak” mean in general terminology and how is it used in Java? Wikipedia definition A memory leak, in computer science (or leakage, in this context), occurs when a computer program consumes memory but ...

Read More »

How to get C like performance in Java

Overview Java has many areas which can be slow. However for every problem there is a solution. Many solutions/hacks require working around Java’s protections but if you need low level performance it is still possible. Java makes high level programming simpler and easier at the cost of making low level programming much harder. Fortunately most applications follow the rule of ...

Read More »

JVM options: -client vs -server

Have you ever wonder what is this -client or -server switch when you run your java app? e.g.: javaw.exe -client com.blogspot.sdoulger.LoopTest that are also displayed in the Help of the java.exe e.g. where options include: -client to select the “client” VM -server to select the “server” VM What’s the difference between the -client and -server systems? These two systems are ...

Read More »

Incorrect Core Java Interview Answers

Overview On the internet, Java interview questions and answers get copied from one web site to another. This can mean that an incorrect or out of date answer might never be corrected. Here are some questions and answer which are not quite correct or are now out of date. i.e. are pre Java 5.0. Every provided question is followed by ...

Read More »

Java 7: try-with-resources explained

This article examines the use of the try-with-resources statement. This is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements the java.lang.AutoCloseable or java.io.Closeable ...

Read More »

Java Secret: Using an enum to build a State machine

Overview The enum in Java is more powerful than many other languages which can lead to surprising uses. In this article, I outline some the individual features of enum in Java, and put them together to form a state machine. Enum for Singleton and Utility class You can use an enum as a Singleton or Utility very simply. enum Singleton ...

Read More »

Low GC in Java: Use primitives instead of wrappers

Overview There are two good reason to use primitives instead of wrappers where possible. Clarity. By using a primitive, you are making it clear that a null value is not appropriate. Performance. Using primitives is often much faster. Clarity is often more important than performance, and is the best reason to use them. However, this article discussed the performance implications ...

Read More »

Java Pretty Good Privacy (PGP)

Public-Key Encryption This post talks about PGP or “Pretty Good Privacy.” PGP is a hybrid implementation of conventional cryptography as well as public key encryption. Before going into the details of PGP, let’s talk a little about public-key encryption. Like any other cryptographic technology, public-key encryption solves the problem of transmitting secure data over an insecure medium; namely, the internet. ...

Read More »