Updates from June, 2007 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 12:50 pm on June 29, 2007 Permalink |  

    iPhone & Java 

    And finally iPhone is here. I -just like any other java mobile developer- am very much excited to know whether iPhone supports java or not. While surfing the net I found people saying “To java or not to java” and thing like that. Many people think “Yeah, it will” and some others “No, I don’t think so, b’ coz during the iPhone promotional events they (Apple guys) didn’t mention anything about it”.

    This is how people reacted to that:
    Source: http://www.javalobby.org/java/forums/t88247.html

    “The iPhone uses an x86 CPU and runs Mac OS X, so of course it runs Java”

    “Doesnt look like it. I see no Java logo anywhere on the iPhone website. You’d think if they can get Safari to run on that thing, then surely they could get Java to run on it! A shame, think of the fun we could have with a 320×480 screen! But… how would Java apps work with the touchscreen? “

    “If this phone was supporting java Steve Jobs wud’ve mentioned it for sure. I have my own doubts abt it supporting java.”

    • No 3rd party applications (probably rules out Java as well)
    • No 3G
    • No Wifi syncing or over the air downloading from iTunes
    • No exchange support

    Based on what we’ve heard so far, it sounds like a nice looking but strangely limited media player that happens to have a marginal phone attached.”

    Wow! Folks, I’m confused too.


    iPhone technical specification
    Screen size – 3.5 inches
    Screen resolution – 320 by 480 pixels (160 ppi)
    Input method – Multi-touch
    Operating system – OS X
    Storage – 4GB or 8GB
    GSM – Quad-band (850, 900, 1800, 1900 MHz)
    Wireless data – Wi-Fi (802.11b/g) / EDGE / Bluetooth 2.0+EDR
    Camera – 2.0 megapixels

    Talk Time  Up to 8 hours
    Standby Up to 250 hours
    Internet Use Up to 6 hours
    Video Playback Up to 7 hours
    Audio playback Up to 24 hours

    Dimensions – 4.5 x 2.4 x 0.46 inches / 115 x 61 x 11.6mm
    Weight – 4.8 ounces / 135 grams

    Source: apple.com

  • Subinkrishna Gopi 11:22 am on June 29, 2007 Permalink |  

    Iterator vs Enumeration 

    As all of you know both Iterator and Enumeration are used to traverse Collection objects, in a sequential fashion.  Enumeration can be applied to Vector and HashTable. Iterator can be used with most of the Collection objects.

    Differences between Iterator & Enumeration:
    Enumeration is twice as fast as Iterator and uses very less memory. Enumeration is very basic and fits to basic needs. But Iterator is much safer as compared to Enumeration, b’ coz it always denies other threads to modify the collection object which is being iterated by it. Whenever a second thread tries for that Iterator will throw a ConcurrentModificationException. Iterators that do this are known as fail-fast iterators, as they fail quickly and cleanly.

    See what happens to this code segment,

    Vector <String> aVector = new Vector<String>(); 
    Enumeration <String> anEnum = aVector.elements(); 
    Iterator <String> anItr  = aVector.iterator();
    // Traversal using Iterator 
       if (<someCondition>) 
          // This statement will throw ConcurrentModificationException. 
          // Means, Iterator won't allow object modification while it is 
          // getting traversed. Even in the same thread. 
    // Traversal using Enumeration 
       if (<someCondition>) 

    But Iterator provides a safer way to remove elements from the underlying collection during the iteration with well-defined semantics. See the implementation of Iterator. But here the remove() is supported by only those implementations of Collection that supports element removal.

    public interface Iterator 
       boolean hasNext(); 
       Object next(); 
       void remove(); // Optional 

    So the above program part can be re-writen as,

       if (<someCondition>) 
       // Note: 
       // Before using anItr.remove(), the Iterator should 
       // point to any of its elements. The remove() removes the 
       // element which the Iterator corrently pointing to.
       // Otherwise it will throw IllegalStateException  

    Note that Iterator.remove() is the only safe way to modify a collection during iteration. In Enumeration, there is “no safe way” to remove elements from a collection while traversing.

    • ketan 2:47 am on December 11, 2010 Permalink

      @subin this is a nice post explaining difference bt Enumeration and Iteration. There’s one more in my mind.

      List Iterator one of the sub interface can traverse backwards also which enumeration can’t do.

    • javarevisited 1:30 pm on January 10, 2011 Permalink

      Between two Enumeration is older and its there from jdk 1.0 while iterator was introduced later.

      The functionality of Enumeration interface is duplicated by the Iterator interface.
      Iterator has a remove() method while Enumeration doesn’t. Enumeration acts as Read-only interface, because it has the methods only to traverse and fetch the objects, where as using Iterator we can manipulate the objects also like adding and removing the objects.

      to read more see here difference between iterator and enumeration

      to read more about deadlock in java

  • Subinkrishna Gopi 10:37 am on June 28, 2007 Permalink |  

    Java Runtime Environment in Mobile devices 

    What is J2ME?

    J2ME is a subset of Java SE (with limited set of APIs) and is the Java platform for the mobile & embedded devices. J2ME is defined thru the JCP (Java Community Process) and keeps the promise, “portability”. In J2ME, portability is achieved by dividing the targeted devices into different “configurations”.

    CDC: Connected Device Configuration
    CLDC: Commented Limited Device Configuration (rather I would say Limited Connected Device Configuration)

    These configurations comes with their own virtual machines and class libraries to provide the basic set of functionalities to the devices with corresponding configuration.

    CDC comes with a CVM (Compact Virtual Machine) and can support devices with minimum of 2MB of memory and a 32 bit processor. On the other hand, CLDC comes with KVM (K -KiloByte- Virtual Machine) which can support low-end devices with limited memory (128 – 512 KB) and a slower processor (16 or 32 bit). So we can conclude that CLDC is smaller of two configurations.

    What is MIDP then ?

    MIDP (Mobile Information Device Profile) is the J2ME development environment in the CLDC devices. MIDP provides the class libraries for UI, Persistent storage, network & application management. Combined with CLDC and its KVM, MIDP provides the complete Java runtime environment for devices with limited memory and processor power. This JRE allows applications to be downloaded OTA (Over The Air) from various sources as MIDlets.

    MIDP handles,

    • Application life cycle management
    • User & Event interfaces
    • Network connectivity
    • Persistent storage
  • Subinkrishna Gopi 6:26 am on June 28, 2007 Permalink |

    Creating Time Series charts using JFreeChart 

    I have attached a code snippet which can give you a basic idea on creating a time-series chart using JFreeChart. This is a part of JFreeChart samples which come along with the free distribution of JFreeChart.

    // Creating a dataset 
    TimeSeries s1 = new TimeSeries("Name of the Time series", Month.class); 
    s1.add(new Month(2, 2001), 181.8); 
    s1.add(new Month(3, 2001), 167.3); 
    s1.add(new Month(4, 2001), 153.8); 
    s1.add(new Month(5, 2001), 167.6); 
    s1.add(new Month(6, 2001), 158.8); 
    s1.add(new Month(7, 2001), 148.3);
    // Creating the chart 
    JFreeChart chart = ChartFactory.createTimeSeriesChart( 
      "Title of the chart", // title 
      "X axis value",        // x-axis label 
      "Y axis value",        // y-axis label 
      dataset,                // data 
      true,                    // create legend? 
      true,                    // generate tooltips? 
      false                    // generate URLs?);
    // Setting the chart properties 
    // Setting the plot properties 
    XYPlot plot = (XYPlot) chart.getPlot(); 
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); 
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) 
         XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; 
    DateAxis axis = (DateAxis) plot.getDomainAxis();axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); 
    return (chart);

    Online JFreeChart Demo (Java WebStart)
    (What is Java WebStart Technology? )

  • Subinkrishna Gopi 4:46 am on June 28, 2007 Permalink |  

    NetBeans IDE 6.0 Preview (M9) Information 

    The NetBeans IDE is a modular, standards-based, integrated development environment (IDE) written in the Java programming language. The NetBeans project consists of an open source IDE and an application platform, which can be used as a generic framework to build any kind of application. .

    Many of the new features of NetBeans 6.0 have been implemented in Milestone 9 (M9). Therefore, this milestone build is being promoted as the NetBeans 6 Preview release. The focus of this release is improved developer productivity with a smarter, faster editor so download it, check it out and let us know what you think. FCS is scheduled for CY04 2007. For a list of milestones and the product schedule, visit the NetBeans 6.0 Wiki.

    Download the NetBeans IDE 6.0 preview

    Source: netbeans.org

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc