
What is feedmap? Let me cite its authors:
… feedmap is about mapping your blog! Using FeedMap you can tell the world where you are blogging from! Or you can simply search for bloggers right around where you live! Or even better let other local bloggers to discover your blog…
I had a look at this service and I must say its idea is very good. Really you can discover blogs of authors that live in the same town or are even your neighbours. And of course you can make your own blog more discoverable. However, I believe the authors need to improve some things (layout, minor issues and some more important stuff, like not working link). Anyway, great idea! I wish feedmap luck!
Of course I submitted this blog (info on feedmap), and my photoblog (info on feedmap).
Continue reading ‘FeedMap = Blogs + Maps’
I’ve just encountered a movie which describes some of Google Analytics features, which are described there too.
I think it’s worth watching this movie even if you’ve been using this tool.
Usually to print some ouptut you’d use System.out.printl() or System.out.println() method. It’s easy to use but you can face some difficulties in providing output formatted in a specific way.
To format output you can use either of the following methods (they work the same)
System.out.format(String format, Object... args)
System.out.format(Locale l, String format, Object... args)
System.out.printf(String format, Object... args)
System.out.printf(Locale l, String format, Object... args)
This is the way how those methods should be used:
%[argIndex$][flags][width][.precision] conversion
where:
- argIndex - index of the argument passed within the args array
- flags:
- - - left justify
- + - print sign (e.g. +25, -45.7)
- 0 - pad this argument with zeroes
- , - use local specific separators (e.g. 124,567,678.877)
- ( -enclose a negative number in parenthesis
- width - minimum number of characters to print (nice to keep clean columns)
- precision - number of digits that will be printed after decimal delimiter (for floating points)
- conversion:
- b - boolean
- c - basic types that represent Unicode characters (char, Character, byte, Byte, short, Short)
- d - integral types (byte, Byte, short, Short, int, Integer, long, Long, BigInteger)
- f - floating point (float, Float, double, Double, BigDecimal)
- s - string (for any argument type)
In the diagram below I present the hierarchy of most common Exceptions and Errors:
Object
|
|_ Throwable
|
|_ Error
| |
| |_ AssertionError
| |
| |_ LinkageError
| | |
| | |_ ExceptionInInitializerError
| | |
| | |_ NoClassDefFoundError
| | |
| |_ VirtualMachineError
| |
| |_ StackOverflowError
|
|_ Exception
|
|_ RuntimeException
|
|_ NullPointerException
|
|_ IllegalArgumentException
| |
| |_ NumberFormatException
|
|_ IndexOutOfBoundException
| |
| |_ ArrayIndexOutOfBoundException
|
|_ ClassCastException
|
|_ IllegalStateException
Continue reading ‘Exeptions and Errors’
A few months ago I wrote about Xobni, a plugin for Outlook. I created that post basing only on what I learned on their homepage.
A few weeks later Xobni team sent me an email with a special link to the installation file. I downloaded and installed Xobni, and played with it.
I’ve been using it for a couple of weeks now and I must say I’m very satisfied! I’ve been using it most to find emails or attachments in my Inbox or Archive folder; this works pretty fast and is very handy. Searching mailbox has never been easier
It’s also interesting to see the email statistics like characteristics of email traffic, who you keep in touch most frequently, etc. There are even a few more useful features which you can discover yourself
To sum up, I really recommend this Xobni. It’s a great piece of software that can save you much time!
It’s a rule that == is used to compare references, not values. To compare values for equality equals() method should be used.
However, as of Java 5, you can also use == to check if two objects’ values are the same… But it works only for the following wrapper objects, if their primitive counterparts’ values are the same:
- Boolean
- Byte
- Character for values: \u0000 (0) ÷ \u007f (127)
- Byte and Integer for values: -128 ÷ 127
Mixing generics with legacy code
List<String> words = new ArrayList<String>();
words.add("house");
words.add("book");
addSth(words);
private void addSth(List list) {
list.add(new Integer(6));
}
- the above code compiles (but with warnings) and can work fine, at least to the place of addition (if the object was later retrieved from the
List it could break down, e.g. words would be treated as List<String> but Integer objects was retrieved) - this code is unsafe
- generic code is only for the compiler purposes; JVM knows nothing about what really the
List holds
- at runtime both legacy and Java 5 code (with generics) look the same, like pre-generic version
List<String> words = new ArrayList<String>();
System.out.println(words instanceof List<String>); // WON'T COMPILE
The above code won’t compile since all instances of a generic class have the same runtime class, regardless of their actual type parameters.
Instead, you should do as below:
List<String> words = new ArrayList<String>();
System.out.println(words instanceof List); // OK
This is also worth a look:
Collection<String> words = new ArrayList<String>();
List<Integer> numbers = new ArrayList<Integer>();
System.out.println(words.getClass() == numbers.getClass()); // produces "true"
Continue reading ‘Generics’
Sorting
In order to sort a Collection, one should use java.util.Collections class as follows (assuming ArrayList will be used):
List words = new ArrayList();
... //populate list of words
Collections.sort(words);
It’s similar with arrays of objects.
In the above mentioned example the List contained obects of String type. Shall an own object type be used, special rules of sorting must be defined with Comparable or Comparator interfaces.
Continue reading ‘Collections - sorting and searching’
assert Expression1 : Expression2;
- Expression1 is asserted to be true; otherwise
AssertionError (that shouldn’t be handled) is thrown
- Expression2 allows to produce some additional information
- Expression2 MUST result in a value - it generates a String message
- allow testing during the development and debugging
- are disabled at runtime by default
- can be enabled using
-ea or -enableassertions flags and selectively disabled using -da or -disableassertions flags, e.g:
java -ea -da:MyClass NotMyClass - enable in general but disable for MyClass
java -ea -da:net.dobrzanski.util... MyClass - enable in general but disable for all classes from net.dobrzanski.util package and any of its subpackages
java -ea -dsa MyClass, which is shorter version of java -enableassertions -disablesystemassertions MyClass - enable in general but disable in system classes
- DO NOT USE to validate arguments to public methods
- DO NOT USE to validate command line arguments
- USE to validate arguments to private methods
- USE to validate that particular code block will never be reached (use
assert false; in that case)
assert can be used as a key word (as of Java 1.4) or as an identifier, but never both at the same time
Examples:
Shorter version:
private void doSth() {
...
assert (a < b);
// in there, a is lower than b
...
}
Longer version:
private void doSth() {
...
assert (a < b) : "a=" + a + ", b=" + b;
// in there, a is lower than b
...
}
Collections are very important on SCJP exam. It’s useful to remember the following…

Continue reading ‘Collection classes in Java’