Sunday, March 22, 2009

Puzzle 9 – Double Fun

Language – Java | Type – Concept | Last date 25-Mar-2009 9:00 p.m. IST | Points 2

The other day I started writing code for a mission critical application – and I needed to loop over. Bored with the standard integer way of looping I decided to be adventurous and used doubles instead. Can you tell me if I am doing something wrong out here?
1 package com.twisters;
2 public class MyDouble {
3 public static void main(String[] args) {
4 for(double d = 0.0; d != 1.0; d = d + 0.1){
5 System.out.println("Doing a strategic thing here…");
6 }
7 }
8 }

Got an answer? Why don’t you leave it here.

No comments:

Post a Comment

Solution for this question?