background preloader

Developer Notes

Facebook Twitter

Java Traps: Big Decimal. Fortunately, it's now almost common sense for programmers not to use the simple types float 's and double 's for representing monetary values (or any other value preferably :-) due to the impression surrounded with these types. float 's and double 's are further restricted by a fixed set of bits to represent them, hence only a limited set of numbers can be held in these types. Armed with this knowledge, fun code examples can be produced such as the one from bytes.com // Bill Gates has 100,000,000,000 in his savings account. His bank's // statement is printed using: #include int main ( void ) { float y = 1e11F ; printf ( "Your balance is %.2f\n" , y ); return 0 ; } // The bank's computer prints the result as: Your balance is 99999997952 . 00 Yes it's C code not Java, but fun never the less.

Printing This one struck me and some co-workers when we had to convert some numbers to and from XML in a low-level fashion. Java Traps: double. Many traps lay before the apprentice programmer as he walks the path of software development. This article illustrates, through a series of practical examples, the main traps of using Java's simple types double and float . Note, however, that to fully embrace precision in numerical calculations you a text book (or two) on the topic is required. Consequently, we can only scratch the surface of the topic.

That being said, the knowledge conveyed here, should give you the fundamental knowledge required to spot or identify bugs in your code. ==, .equals(), compareTo(), and compare() Equality comparison: One way for primitives, Four ways for objects Comparing Object references with the == and !

==, .equals(), compareTo(), and compare()

= Operators The two operators that can be used with object references are comparing for equality (==) and inequality (! Design Techniques Articles. Exceptions in Java. Exceptions in JavaExceptions in the Java Language and Virtual Machineby Bill VennersFirst Published in JavaWorld, June 1998 Page 1 of 9 >> Summary This tutorial covers the nuts and bolts of what exceptions are and how they work in the Java language and virtual machine. It discusses exception classes and objects, throwing and catching exceptions, the method invocation stack, the throws clause, checked vs. unchecked exceptions, and finally clauses.

Exceptions are the customary way in Java to indicate to a calling method that an abnormal condition has occurred. This article is a companion piece to this month's Design Techniques installment, which discusses how to use exceptions appropriately in your programs and designs. When a method encounters an abnormal condition (an exception condition) that it can't handle itself, it may throw an exception. Java Programming Notes. Java tutorial for beginners. Verify Java Version. Best practice. Everyday I come to the office and I see people working.

best practice

We all work in different ways. Sometimes we work by ourselves, sometimes we pair up to work together on a card we pick from the wall (card = task from the story board). These two ways of working are very different and I would like to share my thoughts on them with you. Caves People need privacy. Caves are also great for pairs whose task is to investigate something that none of the developers in that pair have experience with. Commons When it comes to pairing, people typically use their "personal spaces" or designated spaces, such as pairing desks or pairing rooms.

In the case of the personal spaces, each desk must not limit the access to the PC. There are several variations of the pairing desk set-up. One PC, one screen, one mouse, one keyboard In this configuration, there is only one screen, so the settings must be so the navigator has as good visibility of the screen as the driver. Java Code Geeks. JDK. Acronym JDK (Java Development Kit).

JDK

Formerly foppishly called the SDK (Software Development Kit). It is free, and you may freely distribute any programs you create with it. The most recent 1.7 JDK version is 1.7.0_51.The most recent 1.6 JDK version is 1.6.0_45.Version 1.8 JDK has been released.JET (Just Enough Time) 9.0 supports up to Java 1.7.0_40. The JDK, described here, is for people who want to write their own Java programs. If all you want to do is run them, or browse Applets on the web, you should use the much smaller JRE (Java Runtime Environment) instead. Further, to confuse everyone, Oracle’s marketing people refer to all Java versions 1.2+ as Java 2 and 1.5+ versions as Java 1.7.0_51.

To further confuse you, Oracle refers to the various downloads of Java updates. To use the JDK you must be running W2K/XP/W2003/Vista/W2008/W7-32/W7-64/W8-32/W8-64/W2012/Linux/LinuxARM/LinuxX86/LinuxX64/Ubuntu/Solaris/SolarisSPARC/SolarisSPARC64/SolarisX86/SolarisX64/OSX.

Strings

Canadian Mind Products Java & Internet Glossary. Java programming source code. Patterns. Statics.