<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6793296473626000180</id><updated>2012-02-16T17:27:12.799+02:00</updated><category term='exceptions'/><category term='dirty code'/><category term='catch'/><category term='File'/><category term='separator'/><category term='jdbc'/><category term='try'/><category term='String.valueOf'/><category term='Java List setter addAll'/><category term='condition simplification'/><category term='functional programming'/><category term='String'/><category term='separatorChar'/><category term='statuses'/><category term='parsing'/><category term='strings'/><category term='Java'/><category term='date validation'/><category term='float'/><category term='if'/><category term='CallableStatement'/><title type='text'>Funny Java</title><subtitle type='html'>Those funny java snippets from real code</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-782229671179620888</id><published>2010-07-21T18:15:00.000+03:00</published><updated>2010-07-21T18:18:02.677+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dirty code'/><title type='text'></title><content type='html'>&lt;span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: Calibri, Arial, Verdana, serif; "&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;span class="Apple-style-span"  style="color:#0000FF;"&gt;&lt;span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: Calibri, Arial, Verdana, serif; line-height: normal; white-space: normal; font-size: 16px; "&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; border-collapse: collapse; "&gt;Consider the following code snippet:&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; border-collapse: collapse; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="keyword" style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span class="class"&gt;&lt;span class="keyword" style="color: rgb(0, 0, 255); "&gt;class&lt;/span&gt; &lt;span class="title" style="color: rgb(163, 21, 21); "&gt;SomeClass&lt;/span&gt; {&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="class"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="class"&gt;&lt;/span&gt; &lt;span class="annotation" style="color: rgb(0, 128, 0); "&gt;@SuppressWarnings&lt;/span&gt;(&lt;span class="string" style="color: rgb(163, 21, 21); "&gt;"unused"&lt;/span&gt;)&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt; &lt;span class="keyword" style="color: rgb(0, 0, 255); "&gt;private&lt;/span&gt; Validator validator;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt; ... &lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; border-collapse: collapse; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;code class="java"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; border-collapse: collapse; "&gt;Variable &lt;/span&gt;&lt;/code&gt;validator&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; font-size: 16px; border-collapse: collapse; "&gt; really isn't use. It could be simply removed, by author decided to mark it as @SuppressWarnings("unused") - just in order to make compiler and Eclipse silent. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; font-size: 16px; border-collapse: collapse; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, sans-serif; line-height: normal; white-space: normal; font-size: 16px; border-collapse: collapse; "&gt;Stupid!&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: hidden; font-family: monospace; line-height: 18px; "&gt;&lt;span class="Apple-style-span"    style="font-family:arial, sans-serif;font-size:130%;color:#000000;"&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-size: 16px; line-height: normal; white-space: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-782229671179620888?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/782229671179620888/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/07/consider-following-code-snippet-public.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/782229671179620888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/782229671179620888'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/07/consider-following-code-snippet-public.html' title=''/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-8655903164459550333</id><published>2010-04-22T18:04:00.000+03:00</published><updated>2010-04-22T18:11:04.325+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java List setter addAll'/><title type='text'>Collection setter</title><content type='html'>There is two major ways to write setters for collection-type members.&lt;br/&gt;This example combines both of them.&lt;br /&gt;&lt;pre&gt;&lt;code class="java"&gt;public void setPhones(List&amp;lt;PhoneNumber&amp;gt; phones) throws Exception&lt;br /&gt;{&lt;br /&gt;    this.phones = phones;&lt;br /&gt;    this.phones.clear();&lt;br /&gt;    this.phones.addAll(phones);&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-8655903164459550333?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/8655903164459550333/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/04/setphones.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8655903164459550333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8655903164459550333'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/04/setphones.html' title='Collection setter'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-3511365691542935286</id><published>2010-03-04T16:14:00.000+02:00</published><updated>2010-03-04T16:17:28.521+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='float'/><title type='text'>Compare float numbers</title><content type='html'>This is how Chuck Norris compares float numbers:&lt;br /&gt;&lt;pre&gt;if (!Float.valueOf("0.0").equals(price.getActualPrice()))&lt;br /&gt;{&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-3511365691542935286?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/3511365691542935286/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/03/compare-float-numbers.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/3511365691542935286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/3511365691542935286'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/03/compare-float-numbers.html' title='Compare float numbers'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-8050516571633483085</id><published>2010-02-22T13:44:00.000+02:00</published><updated>2010-02-22T13:50:44.884+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='parsing'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='statuses'/><title type='text'></title><content type='html'>As to me, this is a really unobvious way to parse strings: &lt;pre&gt;&lt;br /&gt;protected void parseSummaryLines()&lt;br /&gt;{&lt;br /&gt;    ...&lt;br /&gt;&lt;br /&gt;    // NOTE: First letters are ommited in order to &lt;br /&gt;    // support capitalized words as well&lt;br /&gt;    String RESULT_GOOD_TEXT_1 = "&lt;font color="red"&gt;othing&lt;/font&gt;";    // Nothing&lt;br /&gt;    String RESULT_GOOD_TEXT_2 = "&lt;font color="red"&gt;uccessful&lt;/font&gt;"; // Successful&lt;br /&gt;    String RESULT_BAD_TEXT_1 = "&lt;font color="red"&gt;&lt;b&gt;assword&lt;/b&gt;&lt;/font&gt;";    // Password&lt;br /&gt;    String RESULT_BAD_TEXT_2 = "&lt;font color="red"&gt;failed&lt;/font&gt;";     // Failed&lt;br /&gt;&lt;br /&gt;    ...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-8050516571633483085?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/8050516571633483085/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/02/as-to-me-this-is-really-unobvious-way.html#comment-form' title='Комментарии: 2'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8050516571633483085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8050516571633483085'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/02/as-to-me-this-is-really-unobvious-way.html' title=''/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-8203232968877526464</id><published>2010-01-07T17:38:00.000+02:00</published><updated>2010-01-07T17:39:07.385+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='functional programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Next generation programming style</title><content type='html'>A very good article about programming:&lt;br /&gt;&lt;a href="http://codemonkeyism.com/generation-java-programming-style/"&gt;http://codemonkeyism.com/generation-java-programming-style/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;in particular, this one is great:&lt;br /&gt;&lt;a href="http://codemonkeyism.com/never-never-never-use-string-in-java-or-at-least-less-often/"&gt;http://codemonkeyism.com/never-never-never-use-string-in-java-or-at-least-less-often/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-8203232968877526464?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/8203232968877526464/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/01/next-generation-programming-style.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8203232968877526464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8203232968877526464'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/01/next-generation-programming-style.html' title='Next generation programming style'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-8461026604330323704</id><published>2010-01-07T17:34:00.000+02:00</published><updated>2010-01-07T17:35:54.766+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='catch'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='try'/><category scheme='http://www.blogger.com/atom/ns#' term='exceptions'/><title type='text'>Bad books samples</title><content type='html'>Today I read a blog entry &lt;a href="http://kaczanowscy.pl/tomek/2010-01/programming-books-promote-code-smells"&gt;How Programming Books Promote Code Smells&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This is true: many books contain examples of bad code.&lt;br /&gt;&lt;br /&gt;One of my favorite examples is the main method with try/catch like &lt;a href="http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml"&gt;this one&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public static void main(String args[]) {&lt;br /&gt;  try{&lt;br /&gt;    FileInputStream fstream = ...&lt;br /&gt;  }catch (Exception e){//Catch exception if any&lt;br /&gt;    System.err.println("Error: " + e.getMessage());&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This try/catch is absolutely NOT NEEDED! If you skip them, the JVM does exactly the same work. the well-known "&lt;a href="http://www.wikijava.org/wiki/10_best_practices_with_Exceptions#Throw_early_catch_late"&gt;Throw early catch late&lt;/a&gt;" principle says that you shoudn't catch exception until you know what to do with it (except the trivial actions that the system does by default).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-8461026604330323704?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/8461026604330323704/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2010/01/bad-books-samples.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8461026604330323704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/8461026604330323704'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2010/01/bad-books-samples.html' title='Bad books samples'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-1477101197087903009</id><published>2009-04-01T11:47:00.000+03:00</published><updated>2009-04-01T11:56:59.129+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CallableStatement'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='jdbc'/><title type='text'>nStartFrom - 12</title><content type='html'>Quite a fun usage of variable &lt;tt&gt;nStartFrom&lt;/tt&gt;:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public void setStatementFromAddress(CCallableStatement ccstmt, &lt;br /&gt;    CAddressStruct address, int nStartFrom) throws SQLException&lt;br /&gt;{&lt;br /&gt;    nStartFrom = nStartFrom - 12; &lt;br /&gt;    ccstmt.setString(nStartFrom + 0, address.getStreet());&lt;br /&gt;    ccstmt.setLong(nStartFrom + 1, address.getCityID());&lt;br /&gt;    ccstmt.setString(nStartFrom + 2, address.getCity());&lt;br /&gt;    ccstmt.setLong(nStartFrom + 3, address.getCountyID());&lt;br /&gt;    ccstmt.setString(nStartFrom + 4, address.getCounty());&lt;br /&gt;    ccstmt.setString(nStartFrom + 5, address.getRegionID());&lt;br /&gt;    ccstmt.setString(nStartFrom + 6, address.getRegion());&lt;br /&gt;    ccstmt.setLong(nStartFrom + 7, address.getCountryID());&lt;br /&gt;    ccstmt.setString(nStartFrom + 8, address.getCountry());&lt;br /&gt;    ccstmt.setString(nStartFrom + 9, address.getZIP());&lt;br /&gt;    ccstmt.setString(nStartFrom + 10, address.getPhone());&lt;br /&gt;    ccstmt.setString(nStartFrom + 11, address.getFax());&lt;br /&gt;    ccstmt.setString(nStartFrom + 12, address.getEMail());&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-1477101197087903009?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/1477101197087903009/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2009/04/nstartfrom-12.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/1477101197087903009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/1477101197087903009'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2009/04/nstartfrom-12.html' title='nStartFrom - 12'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-5118335681033099020</id><published>2009-03-20T12:29:00.000+02:00</published><updated>2009-03-20T12:33:55.292+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='if'/><category scheme='http://www.blogger.com/atom/ns#' term='date validation'/><category scheme='http://www.blogger.com/atom/ns#' term='condition simplification'/><title type='text'>Ugly condition</title><content type='html'>I have found a method for validating date:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// check that it is valid format&lt;br /&gt;//    d,m,y&lt;br /&gt;//    m,y&lt;br /&gt;//    y&lt;br /&gt;if ((nYearFrom != null &amp;&amp; nMonthFrom != null &amp;&amp; nDayFrom != null ||&lt;br /&gt;     nYearFrom != null &amp;&amp; nMonthFrom != null ||&lt;br /&gt;     nYearFrom != null) &amp;&amp;&lt;br /&gt;    (nYearTo != null &amp;&amp; nMonthTo != null &amp;&amp; nDayTo != null ||&lt;br /&gt;     nYearTo != null &amp;&amp; nMonthTo != null ||&lt;br /&gt;     nYearTo != null))&lt;/pre&gt;&lt;br /&gt;After a short thinking, this condition can be simplified to:&lt;br /&gt;&lt;pre&gt;if (nYearFrom != null &amp;&amp; nYearTo != null)&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-5118335681033099020?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/5118335681033099020/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2009/03/ugly-condition.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/5118335681033099020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/5118335681033099020'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2009/03/ugly-condition.html' title='Ugly condition'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6793296473626000180.post-7223364974401168517</id><published>2009-03-20T11:56:00.000+02:00</published><updated>2009-03-20T12:54:19.510+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='separatorChar'/><category scheme='http://www.blogger.com/atom/ns#' term='separator'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='String.valueOf'/><category scheme='http://www.blogger.com/atom/ns#' term='String'/><category scheme='http://www.blogger.com/atom/ns#' term='File'/><title type='text'>File.separatorChar</title><content type='html'>I have just found a funny snippet in Java code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;File pom = new File(dir.getAbsoluteFile()&lt;br /&gt;  + &lt;font color="red"&gt;String.valueOf(File.separatorChar)&lt;/font&gt; + "pom.xml");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Actualy class &lt;tt&gt;java.io.File&lt;/tt&gt; has two constants:&lt;br /&gt;&lt;pre&gt;public static final char separatorChar = '\';&lt;br /&gt;public static final String separator = "" + separatorChar;&lt;/pre&gt;&lt;br /&gt;This is the same symbol, but &lt;i&gt;separatorChar&lt;/i&gt; is a &lt;b&gt;char&lt;/b&gt;, and &lt;i&gt;separator&lt;/i&gt; is a &lt;b&gt;String&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;So, instead if using &lt;tt&gt;String.valueOf(File.separatorChar)&lt;/tt&gt; developer could use &lt;tt&gt;File.separator&lt;/tt&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6793296473626000180-7223364974401168517?l=funny-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://funny-java.blogspot.com/feeds/7223364974401168517/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://funny-java.blogspot.com/2009/03/stringvalueoffileseparatorchar.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/7223364974401168517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6793296473626000180/posts/default/7223364974401168517'/><link rel='alternate' type='text/html' href='http://funny-java.blogspot.com/2009/03/stringvalueoffileseparatorchar.html' title='File.separatorChar'/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:total>0</thr:total></entry></feed>
