RSS

Archivos Mensuales: marzo 2012

Ternary if-else operator in Java


This post is written because something I didn’t know about ternary if-else operator. After some debugging I  finally realized the cause of the outcome.

A basic situation could be as follows:

  • A class called MyClass with a long attribute with a specific constructor.
  • public class MyClass {
    	private long value;
    		public MyClass(long value) {
    		this.value = value;
    	}
    	
    	public long getValue() {
    		return this.value;
    	}
    }
    
  • Another class that creates an instance of the previous class in its main method.
  • public class Example {
    	public static void main(String[] args) 
    		MyClass myClass = new MyClass((3>1) ? null : 3);
    		System.out.println(myClass.getValue());
    	}
    }
    

Try to find the answer out. If you are not sure of it, just copy the code, compile it and execute it … if you are able to. There’s some nice post about this situation in stackoverflow. This is my prefered one.

It seems java compiler tries to evaluate the type of both branches (if-else). It realizes and int value and a null(object) value which might reference to a integer value. Because of that Java compiler doesn’t complain about it. The problem is shown in executing time as long as null value can’t be parsed to a correct integer value.

Anuncios
 
Deja un comentario

Publicado por en 29 marzo, 2012 en Java

 

Etiquetas: ,

FeedHenry on VMware’s Cloud Foundry : mobile app development in the Cloud


feedhenry_logo

logo_header_cloudfoundry

 

 

 

This post is going to give a little introduction to FeedHenry. As you can read on its webpage, FeedHenry:

Build powerful cloud powered apps with FeedHenry. Write in HTML5 and JavaScript. Deploy to your Cloud Foundry, and have a cloud scalable app on 5 platforms instantly!

This means that you can develop you own mobile app, upload your backend to Cloud Foundry and create an Android or iOS client to install into your device to connect. And you can do this just with HTML5, CSS3, JavaScript, Github and a Cloud Foundry account.

Read the rest of this entry »

 
Deja un comentario

Publicado por en 25 marzo, 2012 en Mobile

 

Etiquetas: , , , , , ,

Mobile development with JQuery Mobile and PhoneGap


jquerymobile-logoIn the previous post we explained how to create a mobile version of our HTML5 pages with CSS3 Media Queries. Now it is time to look at another choice we have when mobile development is mentioned: JQuery Mobile. As probably most of you may know there is a great Javascript library so named JQuery that can really help us in order to make web development.

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

Read the rest of this entry »

 
1 comentario

Publicado por en 17 marzo, 2012 en Mobile

 

Etiquetas: , , , , , , , ,

Mobile development with CSS3 Media Queries and JQuery Mobile


css3 logo

Have you already decided to create your own mobile project?. If so, I recommend you take a look at CSS3 Media Queries and JQuery Mobile. In this post I will explain how to use them regarding mobile development.

Read the rest of this entry »

 
6 comentarios

Publicado por en 17 marzo, 2012 en Mobile

 

Etiquetas: , , , , , ,

 
A %d blogueros les gusta esto: