<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>El Mundo de Java &#187; programacion</title>
	<atom:link href="http://www.elmundodejava.es/category/programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elmundodejava.es</link>
	<description>“Un mundo donde te quedarás a vivir”</description>
	<lastBuildDate>Sun, 13 Dec 2009 19:07:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tipos de variables en Java</title>
		<link>http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/</link>
		<comments>http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 19:07:49 +0000</pubDate>
		<dc:creator>Shaddar</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[primitivas]]></category>
		<category><![CDATA[referenciales]]></category>
		<category><![CDATA[tipos]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.elmundodejava.es/?p=82</guid>
		<description><![CDATA[Concepto de variable
Una variable es un contenedor de bits que representan a un valor. Se emplean  para almacenar datos que pueden cambiar durante la ejecución de un programa. En  función de los datos que almacenan se  clasifican en:

Variables primitivas: almacenan datos numéricos, valores lógicos o    caracteres.


Variables referenciadas: asociadas a [...]]]></description>
			<content:encoded><![CDATA[<h2>Concepto de variable</h2>
<p>Una variable es un <strong>contenedor de bits que representan a un valor</strong>. Se emplean  para <strong>almacenar datos que pueden cambiar durante la ejecución de un programa</strong>. En  función de los datos que almacenan se  clasifican en:</p>
<ul>
<li><strong>Variables primitivas:</strong> almacenan datos numéricos, valores lógicos o    caracteres.</li>
</ul>
<ul>
<li><strong>Variables referenciadas: </strong>asociadas a objetos o instancias de una    clase. Por ejemplo, para almacenar cadenas de caracteres se empleará una variable referenciada    asociada a la clase String, para almacenar información sobre la fecha actual,    otra asociada a la clase Date, etc. Se estudiarán más adelante.</li>
</ul>
<p><strong>Además</strong> de estos dos tipos de variables se estudiarán los <strong>arrays de variables  primitivas y de variables referenciadas</strong>. Un array, como se verá en el tema  correspondiente, es una variable referenciada asociada a la clase Object (clase madre  de todos los objetos Java).</p>
<p>Se va a profundizar un poco más en el concepto de variable: como se ha  comentado anteriormente, no es nada más que  un contenedor de bits que representan a un valor. Ocurre lo siguiente:</p>
<ul>
<li><strong>En el caso de variables primitivas, los bits representan un número entero    que coincide con el valor de la variable</strong>, con lo que se va a trabajar a lo    largo del programa. Por ejemplo, se tienen variables de tipo byte (utilizan 8    bits en memoria) que pueden almacenar números enteros comprendidos entre -128    y 127, de tipo int (utilizan 32 bits en memoria) para almacenar enteros entre,    aproximadamente, -2150 millones y 2150 millones, de tipo float para números    decimales, etc.</li>
</ul>
<p style="text-align: center;"><img class="aligncenter" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020070.gif" border="0" alt="" width="270" height="228" /></p>
<ul>
<li><strong>En el caso de variables referenciadas o asociadas a objetos, los bits    representan un numerajo que permite acceder al valor de la variable, es decir,    al objeto, pero no es el valor u objeto en sí.</strong></li>
</ul>
<p style="text-align: center;"><img class="aligncenter" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020071.gif" border="0" alt="" width="555" height="321" /></p>
<p>Todos los nombres empleados para hacer referencia a variables deben cumplir lo siguiente:</p>
<ul>
<li>Su primer carácter debe ser una letra, el símbolo del subrayado o el    carácter dólar $.</li>
</ul>
<ul>
<li>No son válidos las palabras reservadas de Java.</li>
</ul>
<ul>
<li>No se admiten espacios en blanco.</li>
</ul>
<ul>
<li>Son case-sensitive (sensibles a mayúsculas).</li>
</ul>
<p>Aparte de estas normas conviene que los nombres de las variables indiquen qué  dato almacenan con el fin de facilitar la lectura del programa y, por otra  parte, si un nombre tiene más de dos palabras la primera letra de la primera  palabra irá en minúscula, la primera letra de la segunda palabra en mayúscula,  ídem con la tercera y así sucesivamente.</p>
<p><strong>Ejemplo:</strong></p>
<p>int miVariableEntera=100;</p>
<h2>Variables primitivas</h2>
<ul>
<li>
<h3><strong>De tipo entero:</strong></h3>
</li>
</ul>
<p style="padding-left: 30px;">Son variables que <strong>almacenan números enteros</strong>. Se pueden dividir en los    siguientes tipos:</p>
<p style="text-align: center;"><img class="aligncenter" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020000.gif" border="0" alt="" width="439" height="191" /></p>
<table id="AutoNumber46" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="100%" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td><strong>NOTA:</strong> el tipo de variable en que se almacena por defecto un numero entero  es int. El valor por defecto asociado a cualquier variable entera no  inicializada es 0.</td>
</tr>
</tbody>
</table>
<ul>
<li>
<h3><strong>De tipo real o de coma flotante:</strong></h3>
</li>
</ul>
<p style="padding-left: 30px;">Son variables que <strong>almacenan datos numéricos con decimales</strong>. Se pueden    dividir en los siguientes tipos:</p>
<p style="text-align: center;"><img class="aligncenter" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020001.gif" border="0" alt="" width="616" height="155" /></p>
<table id="AutoNumber47" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="100%" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td><strong>NOTA:</strong> el tipo de variable en que se almacena por defecto un numero  decimal es double. El valor por defecto asociado a cualquier variable real no  inicializada es 0.0.</td>
</tr>
</tbody>
</table>
<ul>
<li>
<h3><strong>De tipo lógico o booleanas:</strong></h3>
</li>
</ul>
<p style="padding-left: 30px;">Son variables que <strong>almacenan dos posibles valores: true o false</strong>. No se    corresponden con ningún valor numérico.</p>
<p style="padding-left: 30px;"><strong>Ejemplo:</strong></p>
<blockquote>
<p style="padding-left: 30px;">boolean tienesCalor=true;</p>
</blockquote>
<table id="AutoNumber48" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="100%" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td><strong>NOTA:</strong> el valor por defecto asociado a cualquier variable booleana no  inicializada es false.</td>
</tr>
</tbody>
</table>
<ul>
<li>
<h3><strong>De tipo char o de carácter:</strong></h3>
</li>
</ul>
<p style="padding-left: 30px;">Son variables que <strong>almacenan caracteres individuales</strong> (letra, numero,    signo ?, etc&#8230;). El carácter que se inicializa debe ir entre apóstrofes o    comillas simples &#8216;a&#8217;.</p>
<p style="padding-left: 30px;"><strong>El código de caracteres empleado por Java es Unicode</strong> y recoge los    caracteres de prácticamente todos los idiomas importantes del mundo (son unos    65.536). Los <strong>caracteres Unicode del alfabeto occidental</strong> corresponden a    los primeros 256 enteros; es decir <strong>van desde [0, 255]</strong>.</p>
<p style="padding-left: 30px;">A cada carácter le corresponde unívocamente un número entero perteneciente    al intervalo [0, 65536] o a [0, 255] si se trabaja sólo con el alfabeto    occidental. Por ejemplo, la letra ñ es el entero 164. Más adelante se verá que    el casting entre variables primitivas enteras y la variable char está    permitido.</p>
<p style="padding-left: 30px;"><strong>Ejemplo: </strong></p>
<blockquote><p>char miCaracter=&#8217;n';<br />
char miCaracter1=110;    (ídem antes, pero mediante el    entero que le corresponde según Unicode)<br />
char miCaracter2=&#8217;\u006E&#8217;; (ídem antes, pero según notación Unicode. La    notación Unicode, en general, es así: \uXXXX siendo X un dígito o cifra    fundamental del sistema de numeración hexadecimal (0,1,2,&#8230;,9,A,B,&#8230;,F))</p></blockquote>
<p style="padding-left: 30px;">Asociado a este tipo de variable se tienen las <strong>secuencias de escape</strong>. Se    emplean para representar caracteres especiales (por ejemplo, unas comillas    dentro de una instrucción que exige una cadena entrecomillada) y caracteres no    imprimibles como el tabulador, salto de línea, etc. Van precedidos de la    contrabarra. Algunos de ellos se detallan en la tabla siguiente:</p>
<p style="text-align: center;"><img class="aligncenter" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020002.gif" border="0" alt="" width="309" height="115" /></p>
<table id="AutoNumber52" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="938" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td width="932"><strong>NOTA:</strong> el valor por defecto asociado a cualquier variable char no  inicializada es &#8216;\u0000&#8242;</td>
</tr>
</tbody>
</table>
<p><strong>Ejemplo: todos los códigos de este tema se guardarán en c:\cursojava\tema2</strong></p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020006.gif" border="0" alt="" width="636" height="214" /></p>
<p style="padding-left: 30px;"><a href="http://www.adrformacion.com/curso/java/leccion2/AsignaOtras.txt" target="_blank">Código fuente</a></p>
<p style="padding-left: 30px;"><strong>Por consola:</strong></p>
<blockquote><p>Comienza programa<br />
El valor de tengoCalor es true<br />
El valor        de letra es n<br />
El valor        de letra1 es n<br />
El valor        de letra2 es n<br />
Eso es<br />
un mensaje<br />
de tres lineas<br />
Me llamo &#8220;Jesus&#8221;<br />
Me llamo \Jesus\</p></blockquote>
<h2>Variables referenciadas</h2>
<p>Asociadas a objetos o instancias de una clase. Se irán estudiando durante    el curso.</p>
<h2>Casting o transformaciones de tipo</h2>
<p>El casting es un procedimiento para <strong>transformar una variable primitiva de    un tipo a otro, o transformar un objeto de una clase a otra clase siempre y    cuando haya una relación de herencia entre ambas</strong> (este último casting es el    más importante y se verá más adelante).</p>
<p>Dentro del casting de variables primitivas se distinguen dos clases:</p>
<ul>
<li><strong>Implícito</strong>: no se necesita escribir código para que se lleve a cabo. Ocurre  cuando se realiza una conversión ancha (widening casting), es decir, cuando se  coloca un valor pequeño en un contenedor grande.</li>
</ul>
<p style="padding-left: 30px;"><strong>Ejemplo 1:</strong></p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020072.gif" border="0" alt="" width="606" height="34" /></p>
<p style="padding-left: 30px;"><strong>Ejemplo 2:</strong> similar al anterior.</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020078.gif" border="0" alt="" width="632" height="50" /></p>
<p style="padding-left: 30px;">En cambio,</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020079.gif" border="0" alt="" width="593" height="51" /></p>
<ul>
<li><strong>Explícito</strong>: sí es necesario escribir código. Ocurre cuando se realiza  una conversión estrecha (narrowing casting), es decir, cuando se coloca un valor  grande en un contenedor pequeño. Son susceptibles de pérdida de datos.</li>
</ul>
<p style="padding-left: 30px;"><strong>Ejemplo 1:</strong></p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020073.gif" border="0" alt="" width="572" height="50" /></p>
<table id="AutoNumber53" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="722" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td width="716"><strong>NOTA:</strong> si se sustituyera la primera línea int num1=100 por int  num1=1000000, el código compilaría bien, pero habría pérdida de datos, pues el 1000000 se  sale del rango de short [-32768, 32767]. Al mostrar por consola el valor se  obtendría un resultado incongruente.</td>
</tr>
</tbody>
</table>
<p style="padding-left: 30px;"><strong>Ejemplo 2:</strong></p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020074.gif" border="0" alt="" width="570" height="49" /></p>
<p style="padding-left: 30px;"><strong>Ejemplo 3:</strong> continuación del Ejemplo 2 del casting implícito</p>
<p style="padding-left: 30px;">Para que la línea</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020080.gif" border="0" alt="" width="207" height="25" /></p>
<p style="padding-left: 30px;">compile debe hacerse un casting explícito a long</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020068.gif" border="0" alt="" width="461" height="19" /></p>
<p style="padding-left: 30px;">pero no</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020069.gif" border="0" alt="" width="498" height="22" /></p>
<p style="padding-left: 30px;">porque, en la línea anterior, 10000000000 es considerado int, mientras que en  las de arriba, double.</p>
<p style="padding-left: 30px;">Dicho esto, se va a analizar un ejemplo un tanto extraño.</p>
<ul>
<li><strong>Ejemplo extraño:</strong></li>
</ul>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020075.gif" border="0" alt="" width="130" height="19" /></p>
<p style="padding-left: 30px;">Dado que cualquier entero, por defecto, se almacena en un int (4 bytes), con  la línea anterior se pretende colocar un valor grande (el int 10) en un  contenedor pequeño (una primitiva de tipo byte con capacidad para 1 byte). Esto,  según lo expuesto anteriormente, precisa de casting explícito.</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020076.gif" border="0" alt="" width="393" height="26" /></p>
<p style="padding-left: 30px;">Pero, resulta que no hace falta, ya que el compilador, <strong>cuando se trabaja con  enteros</strong>, digamos que, provoca un &#8220;<strong>casting implícito contranatura</strong>&#8221; y transforma  automáticamente a byte el int 10. Ocurriría lo mismo si se trabajara con short y  char.</p>
<p style="padding-left: 30px;">Lo que pasa (y esto es lo que resulta un tanto extraño) es que no ocurre lo  anterior con los decimales: por eso, una línea como</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020077.gif" border="0" alt="" width="158" height="23" /></p>
<p style="padding-left: 30px;">provoca error de compilación. Recordar que cualquier decimal, por defecto, se  almacena en un double (8 bytes) y que un tipo float tiene capacidad para 4 bytes. En los  decimales, el compilador no fuerza el casting implícito contranatura. De ahí que  sea necesario un casting explícito a float para evitar el fallo de compilación.</p>
<table id="AutoNumber54" style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="2" width="100%" bgcolor="#d7e4ec" bordercolor="#4a5a64">
<tbody>
<tr>
<td><strong>NOTA:</strong> quizá se evitarían estas situaciones, si el compilador no forzara el casting  implícito contranatura a byte, short o char de un int y provocara error de compilación, del mismo modo que  cuando se declara un float y no se castea explícitamente. Pero, de momento, esto  es lo que hay.</td>
</tr>
</tbody>
</table>
<ul>
<li><strong>Código de partida para explicar el casting entre variables primitivas que  almacenan datos numéricos:</strong></li>
</ul>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020007.gif" border="0" alt="" width="641" height="156" /></p>
<p style="padding-left: 30px;">Las líneas 3 y 4 almacenan al número 10 mediante una variable primitiva    de tipo byte vía &#8220;casting implícito contranatura&#8221;, el 3000 mediante una de tipo short,    también vía &#8220;casting implícito contranatura&#8221;. Lo más intuitivo es    definirlas mediante un casting explícito, pero tal y como están también se    puede.</p>
<p style="padding-left: 30px;">Supuestamente, la línea 5, almacena el 3000000000 mediante una variable de tipo long,    vía casting implícito, pero es falso. Ocurre lo que se ha comentado    en el Ejemplo 2 del casting implícito: 3000000000 no es considerado como long sino como int y 3000 millones no    pertenece al rango asociado a int (aprox. [-2150 millones, 2150 millones]). Si    se intenta compilar, se produciría error.</p>
<p style="padding-left: 30px;">Supuestamente, la línea 6, almacena el 256.5 mediante una variable de tipo float    (ocupa 4 bytes en memoria), vía &#8220;casting implícito contranatura&#8221;, pero, como se    ha comentado en el Ejemplo extraño, es falso,    ya que en decimales nunca se produce. Debe castearse explícitamente a float.</p>
<p style="padding-left: 30px;">El código correcto sería:</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020008.gif" border="0" alt="" width="629" height="365" /></p>
<p style="padding-left: 30px;"><a href="http://www.adrformacion.com/curso/java/leccion2/EjemploCasting1.txt" target="_blank">Código fuente</a></p>
<ul>
<li><strong>Una cuestión a tener en cuenta relacionada con el casting entre    variables primitivas es la siguiente:</strong></li>
</ul>
<p style="padding-left: 30px;">En Java se realizan automáticamente conversiones de una variable primitiva    de un tipo a otra de otro de igual o mayor precisión.</p>
<p style="padding-left: 30px;">La precisión depende del número de bytes ocupados en memoria y del rango de    valores asociado: a mayor número de bytes ocupados, mayor precisión y mayor    rango asociado. Así, pasar de byte a short, de short a int, de byte a int, .    es automático; en definitiva: pasar de una variable primitiva de un tipo de la    cadena de la siguiente línea a otra que se encuentre a su derecha es    automático.</p>
<p style="padding-left: 30px;">byte&#8211;&gt;short&#8211;&gt;int&#8211;&gt;long&#8211;&gt;float&#8211;&gt;double</p>
<p style="padding-left: 30px;">Así, por ejemplo, <strong>si un método necesita un long como argumento y se le  pasa un entero perteneciente al rango de int, promociona automáticamente a long  y no es necesario casting.</strong></p>
<p style="padding-left: 30px;">En cambio, <strong>si se le pasa un entero que se sale fuera del rango de int, es  necesario realizar un casting para que la llamada al método no provoque error al  compilar.</strong></p>
<p style="padding-left: 30px;">Un ejemplo de esto ocurre con el método estático de java.lang.Thread &#8220;void sleep(long  retardo)&#8221; que introduce un retardo en la ejecución del código, coincidente  con el entero, en milisegundos, que se le pasa al argumento. Este método se estudiará más adelante.</p>
<p><img class="alignnone" style="border: 0pt none;" src="http://www.adrformacion.com/curso/java/leccion2/img020065.gif" border="0" alt="" width="643" height="124" /></p>
<p style="padding-left: 30px;"><strong>Por consola:</strong></p>
<blockquote><p>Hola<br />
&#8211; Después de tres segundos &#8211;<br />
Adios</p></blockquote>
<p style="padding-left: 30px;"><strong>En cambio, si se sustituye </strong></p>
<p style="padding-left: 30px;">Thread.sleep(3000) por Thread.sleep(3000000000)</p>
<p style="padding-left: 30px;">no compila ya que el entero que se le pasa no pertenece al rango de int y no  puede promocionar a long automáticamente.</p>
<p style="padding-left: 30px;">Para que compile es necesario hacer un casting explícito:</p>
<p style="padding-left: 30px;">Thread.sleep(3000000000L)</p>
<ul>
<li><strong>Para finalizar con el casting entre primitivas, conviene tener en cuenta lo  siguiente:</strong></li>
</ul>
<p style="padding-left: 30px;">No es posible realizar casting entre una variable primitiva  booleana y    cualquier otra variable primitiva.</p>
<p style="padding-left: 30px;">Sí es posible realizar casting entre una variable primitiva char y una    variable primitiva que almacene enteros.</p>
<p style="padding-left: 30px;"><strong>Ejemplo:</strong></p>
<p><img src="http://www.adrformacion.com/curso/java/leccion2/img020005.gif" border="0" alt="" width="641" height="108" /></p>
<p style="padding-left: 30px;"><a href="http://www.adrformacion.com/curso/java/leccion2/EjemploCastingChar.txt" target="_blank">Código fuente</a></p>
<p style="padding-left: 30px;"><strong>Por consola:</strong></p>
<blockquote><p>ñ<br />
ñ</p></blockquote>
<p><img id="myFxSearchImg" style="border: medium none ; position: absolute; z-index: 2147483647; opacity: 0.6; display: none;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<div  class="related_post_title">Entradas relacionadas</div><ul class="related_post"><li><a href="http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/" title="Los mejores libros para aprender Java">Los mejores libros para aprender Java</a></li><li><a href="http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/" title="Si los lenguajes de programación fuesen personas">Si los lenguajes de programación fuesen personas</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/" title="Comparación entre algoritmos de ordenación">Comparación entre algoritmos de ordenación</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/algo-de-historia/" title="Algo de historia de Java&#8230;">Algo de historia de Java&#8230;</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Los mejores libros para aprender Java</title>
		<link>http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/</link>
		<comments>http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 09:59:00 +0000</pubDate>
		<dc:creator>Shaddar</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[aprender]]></category>
		<category><![CDATA[libros]]></category>
		<category><![CDATA[mejor]]></category>
		<category><![CDATA[mejores]]></category>
		<category><![CDATA[metodo]]></category>

		<guid isPermaLink="false">http://www.elmundodejava.es/?p=54</guid>
		<description><![CDATA[Buscando libros de java me he encontrado con una lista con los mejores libros para aprender este lenguaje de programación:
 
1. Objects First With Java: A Practical Introduction Using BlueJ (2nd Edition) 
Autor: Michael Kölling
Descripción: 
Start by learning about objects, first; what a great idea! This book begins with the direct manipulation of objects. No [...]]]></description>
			<content:encoded><![CDATA[<p>Buscando libros de java me he encontrado con una lista con los mejores libros para aprender este lenguaje de programación:</p>
<p><a href="http://www.amazon.com/Objects-First-Java-Practical-Introduction/dp/0131249339/ref=cm_lmf_img_1"><img class="alignleft" style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/51N7NBG899L._SL110_.jpg" border="0" alt="Objects First With Java: A Practical Introduction Using BlueJ (2nd Edition)" width="84" height="110" align="center" /></a><span id="lm_asinlink95" style="line-height: 14px;"><strong> </strong></span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>1. <a href="http://www.amazon.com/Objects-First-Java-Practical-Introduction/dp/0131249339/ref=cm_lmf_tit_1">Objects First With Java: A Practical Introduction Using BlueJ (2nd Edition)</a></strong> </span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>Autor:</strong> Michael Kölling</span></p>
<p><span style="line-height: 14px; padding-bottom: 50px;"><strong>Descripción: </strong></span></p>
<p>Start by learning about objects, first; what a great idea! This book begins with the direct manipulation of objects. No public static void main until the 4th chapter.</p>
<p><a href="http://www.amazon.com/Head-First-Java-Bert-Bates/dp/0596004656/ref=cm_lmf_img_2"><img class="alignleft" style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/616zKXe2yHL._SL110_PIsitb-sticker-arrow-sm,TopRight,10,-13_OU01_.jpg" border="0" alt="Head First Java" width="83" height="98" align="center" /></a><span id="lm_asinlink95" style="line-height: 14px;"><strong> </strong></span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>2.  <a href="http://www.amazon.com/Head-First-Java-Bert-Bates/dp/0596004656/ref=cm_lmf_tit_2">Head First Java</a></strong> </span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>Autor:</strong></span><span id="lm_asinlink95" style="line-height: 14px;"> Kathy Sierra</span></p>
<p><strong>Descripción:</strong></p>
<p>Left brain + right brain + humor = comprehension. Written by the founder of Javaranch.com, herself.</p>
<p><a href="http://www.amazon.com/Java-Nutshell-Fourth-David-Flanagan/dp/0596002831/ref=cm_lmf_img_3"><img class="alignleft" style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/51SXVwuxXzL._SL110_PIsitb-sticker-arrow-sm,TopRight,10,-13_OU01_.jpg" border="0" alt="Java in a Nutshell, Fourth Edition" width="77" height="113" align="center" /></a></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>3.  <a href="http://www.amazon.com/Java-Nutshell-Fourth-David-Flanagan/dp/0596002831/ref=cm_lmf_tit_3">Java in a Nutshell, Fourth Edition</a></strong> </span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>Autor:</strong></span><span id="lm_asinlink95" style="line-height: 14px;"><br />
David Flanagan</span></p>
<p><strong>Descripción: </strong></p>
<p><strong> </strong>The only paper reference book you will need.</p>
<p><a href="http://www.amazon.com/Java-TM-Developers-Guide-Eclipse/dp/0321159640/ref=cm_lmf_img_4"><img class="alignleft" style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/51RYZR5B44L._SL110_PIsitb-sticker-arrow-sm,TopRight,10,-13_OU01_.jpg" border="0" alt="The Java(TM) Developer's Guide to Eclipse" width="79" height="99" align="center" /></a></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>4.  <a href="http://www.amazon.com/Java-TM-Developers-Guide-Eclipse/dp/0321159640/ref=cm_lmf_tit_4">The Java(TM) Developer&#8217;s Guide to Eclipse</a></strong> </span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>Autor:</strong> Sherry Shavor</span></p>
<p><span style="line-height: 14px;"><strong>Descripción: </strong></span></p>
<p>You need to learn a powerful IDE, and this is one of the best. The first half deals with learning to use the IDE and the second half shows you how to write plugins for Eclipse.</p>
<p><a href="http://www.amazon.com/Certified-Programmer-Developer-310-035-310-027/dp/0072226846/ref=cm_lmf_img_5"><img class="alignleft" style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/51TqABdwUeL._SL110_PIsitb-sticker-arrow-sm,TopRight,10,-13_OU01_.jpg" border="0" alt="Sun Certified Programmer &amp; Developer for Java 2 Study Guide (Exam 310-035 &amp; 310-027)" width="80" height="99" align="center" /></a></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>5.  <a href="http://www.amazon.com/Certified-Programmer-Developer-310-035-310-027/dp/0072226846/ref=cm_lmf_tit_5">Sun Certified Programmer &amp; Developer for Java 2 Study Guide (Exam 310-035 &amp; 310-027)</a></strong> </span></p>
<p><span id="lm_asinlink95" style="line-height: 14px;"><strong>Autor:</strong> Kathy Sierra</span></p>
<p><span style="line-height: 14px;"><strong>Descripción: </strong></span></p>
<p>Only if you want to be certifiable! This is a great companion book to Head First Java.</p>
<p><img id="myFxSearchImg" style="border: medium none ; position: absolute; z-index: 2147483647; opacity: 0.6; display: none;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<div  class="related_post_title">Entradas relacionadas</div><ul class="related_post"><li><a href="http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/" title="Si los lenguajes de programación fuesen personas">Si los lenguajes de programación fuesen personas</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/" title="Comparación entre algoritmos de ordenación">Comparación entre algoritmos de ordenación</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/algo-de-historia/" title="Algo de historia de Java&#8230;">Algo de historia de Java&#8230;</a></li><li><a href="http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/" title="Tipos de variables en Java">Tipos de variables en Java</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Si los lenguajes de programación fuesen personas</title>
		<link>http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/</link>
		<comments>http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 11:01:41 +0000</pubDate>
		<dc:creator>Shaddar</dc:creator>
				<category><![CDATA[humor]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascrip]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.elmundodejava.es/?p=43</guid>
		<description><![CDATA[¿Qué pasa si los lenguajes de programación son personas reales como tú y yo? ¿Y si eran parte de las familias y tenía relaciones y los asuntos? ¿Alguna vez has pensado en ir a un supermercado y Visual Basic era la mujer joven que esperaba en la fila delante de usted?
Así lo hicieron los de [...]]]></description>
			<content:encoded><![CDATA[<p><span id="result_box"><span style="background-color: #ffffff;" title="What if programming languages were real persons like you and me?" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">¿Qué pasa si los lenguajes de programación son personas reales como tú y yo? </span><span style="background-color: #ffffff;" title="What if they were parts of families and had relations and affairs?" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">¿Y si eran parte de las familias y tenía relaciones y los asuntos? </span><span style="background-color: #ffffff;" title="Have you ever thought of going to a supermarket and Visual Basic was the young woman waiting in the line in front of you?" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">¿Alguna vez has pensado en ir a un supermercado y Visual Basic era la mujer joven que esperaba en la fila delante de usted?</span></span></p>
<p><span title="Well we did." onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">Así lo hicieron los de <a href="http://jeez.eu">jeez.eu</a> con su articulo de </span><a title="If Programming Languages Were Real Persons" rel="bookmark" href="http://jeez.eu/2009/11/03/if-programming-languages-were-real-persons/">If Programming Languages Were Real Persons</a>, una traducción aproximada la podeis encontrar <a href="http://mundogeek.net/archivos/2009/11/05/si-los-lenguajes-de-programacion-fuesen-personas/">aquí</a>.</p>
<h3>Charlie C</h3>
<p><img class="alignright" title="C" src="http://jeez.eu/wp-content/uploads/2009/11/C.png" alt="C" width="250" height="261" />C is a 70 years old man that knows a lot. Perhaps too proud to reveal what he knows and sometimes too cryptic. He is a very strict person that follows his way of doing things and nothing seems possible to change his mind. In the past he was known as one of the strictest teachers in the Devel City university.</p>
<p>C can make you happy or disappoint you so much that, you want go for one of his sons or daughters. It depends on how much you try to learn his ways. The more you try the more he gives you.</p>
<p>C has been the main builder behind large projects like the Linuxious stadium and other large scaled buildings that we all use. He still works as a freelancer engineer and has involved in many other projects. Even at his age and with a lot of competition mainly from his son C++, C is still the choice of many companies to do things in Devel City.</p>
<p>C has 3 daughters :</p>
<ul>
<li>Perl,</li>
<li>Java and</li>
<li>C#</li>
</ul>
<p>and one son, C++.</p>
<h3>Vin C++</h3>
<p><img class="alignright" title="KD-Scientist-GS72" src="http://jeez.eu/wp-content/uploads/2009/11/KD-Scientist-GS721.gif" alt="KD-Scientist-GS72" width="250" height="300" />C++ is 45 years old teacher at the Devel City university, following his father’s steps to become as respected as he is. He loves his father so much that tried to continue his work and knowledge. Being a younger man than C though, made him a much more friendly guy, in the means of approach, than his father. He works as a teacher in the Devel City university and his students have a love and hate affair with him.</p>
<p>C++ often lets his students choose their way in the learning process since he follows a different way of teaching approach than his father used to. His students love him because he lets them work in their own way but sometimes they fear his inheritance of C.</p>
<p>Most of his followers admire his wide range of knowledge that mixes C’s knowledge with knowledge gained through his life.</p>
<p>There are also a lot of people that criticise him of being so wide. Most of the time they talk about him as a direct descendant of C that has adopted all of his fathers disadvantages and added some more to it.</p>
<p>C++ has spent many years to get rid some of his fathers bad habits and never does things not needed. He prefers to put as much effort as needed to do the job right and never bloats things. This is why his projects are much more targeted than his fathers.</p>
<h3>Montana Perl</h3>
<p><img class="alignright" title="perl" src="http://jeez.eu/wp-content/uploads/2009/11/perl.png" alt="perl" width="250" height="303" />Perl is a 37 years old young woman and works as a data analyst at the department of linguistics in Devel City. As a sexy young woman, her colleagues just love to work with her.</p>
<p>She is extremely clever, very strict when it comes to how people treat to her but has added great value to her carrier with her regular way of expressing things and her unique way of finding needles in haystacks. Many of her colleagues depend on Perl to fix things and they call her a “Swiss knife”.</p>
<p>Her father was a source of inspiration for Perl. Many of her father’s principles was inherited and many more added to her philosophy of how things should be done and why. She is a rather laconic character that speaks less but means a lot.</p>
<p>Perl finds it easy to work on different environments and performs well with a little help from her beloved husband Cygwin who always supports her ambitions.</p>
<p>Perl loves to travel. Each summer she goes around the world, most of the time she will be riding a camel in Africa and many times you might find her playing Golf in the State of the union stadium.</p>
<p>She also loves poetry and runs her own amusement company named Acme which aids in teaching young kids the way to do things the funny way.</p>
<h3>Bianca Java</h3>
<p><img class="alignright" title="java" src="http://jeez.eu/wp-content/uploads/2009/11/java1.png" alt="java" width="250" height="284" />Java is a 35 years old sexy young woman and a mother also. Being so young and mature, Java is one of the most popular women in Devel City. She is very adoptable and can work everywhere. Her name comes as a feature in many projects and a lot of companies want their projects to carry her “Java powered” signature of quality.</p>
<p>Being C++’s sister, does not stop Java to be one of the biggest competitors of her brother. As a woman, Java is clean and manages to keep garbage out of her place, clean and clear. She works at JVM, a company specialized in ports creation.</p>
<p>Java loves sun. Each summer is Java’s favorite season and she loves playing with Duke in the beach.</p>
<p>Java has created her own legacy, just like her father did and has 2 daughters that promise to be as competitive as she is. Her daughters also work at JVM and stand out from the crowd of talented persons in Devel City. Their names are:</p>
<ul>
<li>Groovy and</li>
<li>Scala</li>
</ul>
<h3>Jessica Groovy</h3>
<p><img class="alignleft" style="margin: 5px;" title="groovy" src="http://jeez.eu/wp-content/uploads/2009/11/groovy.JPG" alt="groovy" width="73" height="98" />Groovy is 21. Young but her impact in Devel City is bigger than just big. She was greatly inspired by her aunt Perl and her best friend Ruby.</p>
<p>Groovy is laconic and very expressive like her aunt, got any possible knowledge of her mother and added some cool ways to do her job in JVM. Most of the time she guides her colleagues in a rather strange way… by adding question marks (?) wherever she thinks something should be checked again.</p>
<h3>Jane Scala</h3>
<p><img class="alignleft" style="margin: 5px;" title="scala" src="http://jeez.eu/wp-content/uploads/2009/11/scala-127x150.jpg" alt="scala" width="76" height="90" />Scala is 22 years old.She is sweet and quite friendly but many of her friends in Devel City feel a little thread when it comes to job opportunities. The case of Twittorix, where the managers of the project asked Scala to do the job, made Ruby upset.</p>
<p>Scala like her little sister Groovy, got all of her mother’s knowledge and took it to a newer level. Not only Scala can work the same way as her mother does, she can also make new ways of working and doing things for a specific job which makes her a valuable part of JVM. Scala gets a lot of suggestions to work for NET (another ports creation company) but she is too busy with JVM at the moment that makes this a little hard to accomplish.</p>
<h3>Pierson PHP</h3>
<p><img class="alignright" title="php" src="http://jeez.eu/wp-content/uploads/2009/11/php.jpg" alt="php" width="250" height="224" />PHP is 29 years old and Java’s bitter friend. PHP runs her own company in Devel City called Zendix and has become one of the worlds well known ladies because of her easy way of doing things, her adoption of new technologies and a large fun club that make her desirable and efficient.</p>
<p>PHP was a student of C, Java’s father and used to work with Perl where she got her expressive character and power. Being a very beautiful woman, PHP has a lot of admirers that range from newcomers to Devel city, to old residents. She might seem easy but she needs a lot of attention to master her ways.</p>
<p>Sometimes her affairs are too strong and sometimes people seem to glance at Java and Ruby which makes her trying to add some of Java’s charm into her character. This, makes a lot of people say that PHP tries to become Java in some way.</p>
<p>Recently, PHP was voted as the 3rd most popular person in Devel’s city Object’s awards.</p>
<h3>Mary JavaScript</h3>
<p><img class="alignright" title="javascript" src="http://jeez.eu/wp-content/uploads/2009/11/javascript-487x600.jpg" alt="javascript" width="250" height="308" />JavaScript is often confused with Java in Devel City especially from newcomers… but you know what they say that: “where no smoke without fire”. Many rumors say that JavaScript is Java’s half sister but she denies it, so does Java.</p>
<p>JavaScript is 32 and her close friends call her “JS”. She is very strict but relaxed also. This, makes her a wonderful companion for most of Devel’s residents and she is very popular since a large part of the city has used her services at least once.</p>
<p>JS is one of the most successful women in Devel City. She runs a network of more than 20 companies some of which are unique.  jQuerysius, Mootool and Dojodic, to name a few are popping out each and every day.</p>
<p>She works silently and a lot of people think that she spents most of her time to make her job look glamourus. Most of her competitors say that she is good only for that but, to be honest, all of them know that there are some things that only she can accomplish.</p>
<p>She believes that to become successful, you have to keep your friends close and, your enemies closer. So, she tries to cooperate and coexist with all other businessman and businesswoman in Devel City. Everybody loves her even if she breaks things up sometimes.</p>
<h3>Angelina Ruby</h3>
<p><img class="alignright" title="ruby" src="http://jeez.eu/wp-content/uploads/2009/11/ruby.jpg" alt="ruby" width="250" height="327" />Ruby is a good friend of Groovy. She is 20 years old and she is one of the upcoming names in Devel City mainly because of her professional maturity and the way she manages to do a job cleanly and fast. Although Scala, Groovy’s sister, got a big job from Ruby’s hands (case of Twittorix), Ruby is still considered as one of the best professionals out there.</p>
<p>Ruby, became one of the most successful women in City of Devel, after the creation of her Rails company  and got a lot of fame. She also inspired many other famous women in Devel City to start their own Rails-like companies with PHP being one of them with Symfoniac LTD.</p>
<p>She is a very calm person and not fond of surprises. When she works, she wants to have everything there as helpful as it can be for her and her co-workers. Most of the time she applies the POLS principle to her job.</p>
<p>Some Devel City residents state that, if Perl goes away one day, Ruby will do the job as good as she does and with more freedom than with Perl.</p>
<p>Ruby believes in one principle: “Divide and Conquer”, this is why she has divided all of her company groups into Gems. Ruby just needs to use a gem to do a particular job.</p>
<h3>Jack Python</h3>
<p><img class="alignright" title="python" src="http://jeez.eu/wp-content/uploads/2009/11/python-290x300.png" alt="python" width="250" height="259" />One of the most known and respected persons in Devel City, is Python. A 54 years old construction builder. Some people believe that he can use the power of his brain to do magic. Python works in a rather modern way that his age implies and here is where he amazes Devel’s residents.</p>
<p>Python always finds new ways of doing things. If a tool is good to work with, Python will use it with no particular disadvantages. Python is one of the best man in Devel to work with since he allows anyone to work the way he thinks is better.</p>
<p>His favorite words are spam and eggs and his projects are named after his nickname. For example PyGameing station and PyS6000 which was a futuristic TV series.</p>
<p>Python as his name implies, is a snakes lover and has a lot of them as pets. His favorite pet is an Anaconda.</p>
<p>His work has been approved by some of the biggest companies in Devel City like 10^10, Yohaaa and DERN.</p>
<p>bre indica, es un gran amante de las serpientes. Su mascota preferida es una serpiente de nombre Anaconda.</p>
<p>Visto en | <a href="http://jeez.eu/2009/11/03/if-programming-languages-were-real-persons/">Jeez<br />
</a>Visto en | <a href="http://jeez.eu/2009/11/03/if-programming-languages-were-real-persons/"></a><a href="http://mundogeek.net/archivos/2009/11/05/si-los-lenguajes-de-programacion-fuesen-personas/">MundoGeek</a></p>
<p><img id="myFxSearchImg" style="border: medium none ; position: absolute; z-index: 2147483647; opacity: 0.6; display: none;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<div  class="related_post_title">Entradas relacionadas</div><ul class="related_post"><li><a href="http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/" title="Los mejores libros para aprender Java">Los mejores libros para aprender Java</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/" title="Comparación entre algoritmos de ordenación">Comparación entre algoritmos de ordenación</a></li><li><a href="http://www.elmundodejava.es/2009/12/05/algo-de-historia/" title="Algo de historia de Java&#8230;">Algo de historia de Java&#8230;</a></li><li><a href="http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/" title="Tipos de variables en Java">Tipos de variables en Java</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparación entre algoritmos de ordenación</title>
		<link>http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/</link>
		<comments>http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:46:26 +0000</pubDate>
		<dc:creator>Shaddar</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[algoritmo]]></category>
		<category><![CDATA[bubblesort]]></category>
		<category><![CDATA[mergesort]]></category>
		<category><![CDATA[microsystems]]></category>
		<category><![CDATA[ordenacion]]></category>
		<category><![CDATA[pseudocodigo]]></category>
		<category><![CDATA[quicksort]]></category>
		<category><![CDATA[selectionsort]]></category>
		<category><![CDATA[sun]]></category>

		<guid isPermaLink="false">http://www.elmundodejava.es/?p=15</guid>
		<description><![CDATA[
Los algoritmos de ordenación son funciones o métodos que se encargan de ordenar un &#8220;array&#8221; de datos. Existen varios tipos de métodos de ordenación, pero hoy solo vamos a comentar algunos de los más potentes:

QuickSort
MergeSort
SelectionSort
BubbleSort

QuickSort
El ordenamiento rápido (quicksort en inglés) es un algoritmo basado en la técnica de &#8220;divide y vencerás&#8221;, que permite, en promedio, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Algoritmos de ordenación" src="http://www.dialogica.com.ar/digicom/algoritmo-de-google.jpg" alt="" width="240" height="287" /></p>
<p>Los algoritmos de ordenación son funciones o métodos que se encargan de ordenar un &#8220;array&#8221; de datos. Existen varios tipos de métodos de ordenación, pero hoy solo vamos a comentar algunos de los más potentes:</p>
<ul>
<li><em>QuickSort</em></li>
<li><em>MergeSort</em></li>
<li><em>SelectionSort</em></li>
<li><em>BubbleSort</em></li>
</ul>
<p><strong>QuickSort</strong></p>
<p>El <strong>ordenamiento rápido</strong> (<strong>quicksort</strong> en inglés) es un algoritmo basado en la técnica de &#8220;divide y vencerás&#8221;, que permite, en promedio, ordenar <em>n</em> elementos en un tiempo proporcional a <em>n</em> log <em>n</em>.</p>
<p>Quizás este sea el algoritmo de ordenación más rápido que existe.</p>
<p>Representación del algoritmo en pseudo-código:</p>
<blockquote>
<pre style="padding-left: 30px;"> function quicksort(array)
     var list less, greater
     if length(array) ≤ 1
         return array
     select and remove a pivot value pivot from array
     for each x in array
         if x ≤ pivot then append x to less
         else append x to greater
     return concatenate(quicksort(less), pivot, quicksort(greater))</pre>
</blockquote>
<p>Representación del algoritmo en Java:</p>
<blockquote>
<pre style="padding-left: 30px;">private static void quickSort(int[] x, int a, int b) {
	int i = a, j = b;
	int p = x[(a+b)/2];
	int v;
	do{
		while(x[i] &lt; p) i++;
		while(x[j] &gt; p) j--;
		if( i &lt;= j ){
			v = x[j];
			x[j] = x[i];
			x[i] = v;
			i++;
			j--;
		}
	} while (i &lt;= j);
	if( a &lt; j ) quickSort(x,a, j);
	if( b &gt; i ) quickSort(x,i, b);
}</pre>
</blockquote>
<p>Representación del algoritmo gráficamente:</p>
<p><img class="aligncenter" title="Quicksort" src="http://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif" alt="" width="280" height="214" /></p>
<p><strong>MergeSort</strong></p>
<p>El algoritmo de MergeSort se basa en la misma técnica que QuickSort de &#8220;divide y vencerás&#8221;, y su tiempo de ordenación es proporcional a <em>n</em> log <em>n.</em></p>
<p>Representación del algoritmo en pseudo-código:</p>
<blockquote>
<pre style="padding-left: 30px;">function mergesort(array A[x..y])
begin
  if (x-y &gt; 1)):
    array A1 := mergesort(A[x..(int( x+y / 2))])
    array A2 := mergesort(A[int(1+(x+y / 2))..y])
    return merge(A1, A2)
  else:
    return A
end

function merge(array A1[0..n1], array A2[0..n2])
begin
  integer p1 := 0
  integer p2 := 0
  array R[0..(n1 + n2 + 1)]
  while (p1 &lt;= n1 or p2 &lt;= n2):
    if (p1 &lt;= n1 and A1[p1] &lt;= A2[p2]):
      R[p1 + p2] := A1[p1]
      p1 := p1 + 1
    if (p2 &lt;= n2 and A1[p1] &gt; A2[p2]):
      R[p1 + p2] := A2[p2]
      p2 := p2 + 1
  return R
end</pre>
</blockquote>
<p>Representación del algoritmo en Java:</p>
<blockquote>
<pre style="padding-left: 30px;">private static void mergeSort( int[ ] x, int[ ] tmpArray, int left, int right ) {
	if( left &lt; right ) {
		int center = ( left + right ) / 2;
		mergeSort( x, tmpArray, left, center );
		mergeSort( x, tmpArray, center + 1, right );
		merge( x, tmpArray, left, center + 1, right );
	}
}

private static void merge( int[ ] x, int[ ] tmpArray, int leftPos, int rightPos, int rightEnd ) {
	int leftEnd = rightPos - 1;
	int tmpPos = leftPos;
	int numElements = rightEnd - leftPos + 1;
	while( leftPos &lt;= leftEnd &amp;&amp; rightPos &lt;= rightEnd )
		if( x[ leftPos ] &lt;= x[ rightPos ] )
			tmpArray[ tmpPos++ ] = x[ leftPos++ ];
		else
			tmpArray[ tmpPos++ ] = x[ rightPos++ ];
	while( leftPos &lt;= leftEnd )
		tmpArray[ tmpPos++ ] = x[ leftPos++ ];
	while( rightPos &lt;= rightEnd )
		tmpArray[ tmpPos++ ] = x[ rightPos++ ];
	for( int i = 0; i &lt; numElements; i++, rightEnd-- )
		x[ rightEnd ] = tmpArray[ rightEnd ];
}</pre>
</blockquote>
<p>Representación del algoritmo gráficamente:</p>
<p><img class="aligncenter" title="MergeSort" src="http://upload.wikimedia.org/wikipedia/commons/c/c5/Merge_sort_animation2.gif" alt="" width="280" height="237" /></p>
<p><strong>SelectionSort:</strong></p>
<p>El <strong>ordenamiento por selección</strong> (<strong>Selection Sort</strong> en inglés) es un algoritmo de ordenamiento que requiere O<span>(<em>n</em><sup>2</sup>)</span> operaciones para ordenar una lista de n elementos.</p>
<p>Su funcionamiento es el siguiente:</p>
<ul>
<li>Buscar el mínimo elemento de la lísta</li>
<li>Intercambiarlo con el primero</li>
<li>Buscar el mínimo en el resto de la lista</li>
<li>Intercambiarlo con el segundo</li>
</ul>
<p>Representación del algoritmo en pseudo-código:</p>
<blockquote>
<pre style="padding-left: 30px;">para i=1 hasta n-1
    minimo = i;
    para j=i+1 hasta n
        si lista[j] &lt; lista[minimo] entonces
            minimo = j /* (!) */
        fin si
    fin para
    intercambiar(lista[i], lista[minimo])
fin para</pre>
</blockquote>
<p>Representación del algoritmo en Java:</p>
<blockquote>
<pre style="padding-left: 30px;">public static void selectionSort(int[] x) {
	int n = x.length;
	for (int i=0; i&lt;n-1; i++) {
		for (int j=i+1; j&lt;n; j++) {
			if (x[i] &gt; x[j]) {
				int temp = x[i];
				x[i] = x[j];
				x[j] = temp;
			}
		}
	}
}</pre>
</blockquote>
<p>Representación del algoritmo gráficamente:</p>
<p><img class="aligncenter" title="SelectionSort" src="http://upload.wikimedia.org/wikipedia/commons/b/b0/Selection_sort_animation.gif" alt="" width="288" height="288" /></p>
<p><strong>BubbleSort</strong></p>
<p>El <strong>Ordenamiento de Burbuja</strong> (<strong>Bubble Sort</strong> en inglés) es un sencillo algoritmo de ordenamiento. Funciona revisando cada elemento de la lista que va a ser ordenada con el siguiente, intercambiándolos de posición si están en el orden equivocado. Es necesario revisar varias veces toda la lista hasta que no se necesiten más intercambios, lo cual significa que la lista está ordenada. Este algoritmo obtiene su nombre de la forma con la que suben por la lista los elementos durante los intercambios, como si fueran pequeñas &#8220;burbujas&#8221;. También es conocido como el <strong>método del intercambio directo</strong>. Dado que solo usa comparaciones para operar elementos, se lo considera un algoritmo de comparación, siendo el más sencillo de implementar.</p>
<p>Representación del algoritmo en pseudo-código:</p>
<blockquote>
<pre style="padding-left: 30px;">procedure bubbleSort( A : list of sortable items ) defined as:
  do
    swapped := false
    for each i in 0 to length(A) - 2 inclusive do:
      if A[i] &gt; A[i+1] then
        swap( A[i], A[i+1] )
        swapped := true
      end if
    end for
  while swapped
end procedure</pre>
</blockquote>
<p>Representación del algoritmo en Java:</p>
<blockquote>
<pre style="padding-left: 30px;">public static void bubbleSort(int[] x) {
	int n = x.length;
	for (int pass=1; pass &lt; n; pass++) {
		for (int i=0; i &lt; n-pass; i++) {
			if (x[i] &gt; x[i+1]) {
				int temp = x[i];  x[i] = x[i+1];  x[i+1] = temp;
			}
		}
	}
}</pre>
</blockquote>
<p>Representación del algoritmo gráficamente:</p>
<p><img class="aligncenter" title="BubbleSort" src="http://upload.wikimedia.org/wikipedia/commons/3/37/Bubble_sort_animation.gif" alt="" width="280" height="237" /></p>
<p><strong>Comparación de los Algoritmos</strong></p>
<p>Después de explicar los algoritmos, he procedido a cronometrarlos uno a uno ordenando una lista de 10.000 elementos mediante una maquina de Java.</p>
<p>Los resultados fueron los siguientes:</p>
<ol>
<li><strong>QuickSort:</strong> 1.29 ms de media.</li>
<li><strong>MergeSort:</strong> 1.57 ms de media.</li>
<li><strong>BubbleSort:</strong> 49.08 ms de media.</li>
<li><strong>SelectionSort:</strong> 103.77 ms de media.</li>
</ol>
<p>Los archivos utilizados para este procedimiento están <a href="http://www.elmundodejava.es/uploads/Sorts.rar" target="_self">aquí</a>.</p>
<p>Enlaces | <a href="http://es.wikipedia.com">Wikipedia</a></p>
<p><img id="myFxSearchImg" style="border: medium none; position: absolute; z-index: 2147483647; opacity: 0.6; display: none;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 2984px; width: 1px; height: 1px;">Los resultados fueron los siguientes:</div>
<div  class="related_post_title">Entradas relacionadas</div><ul class="related_post"><li><a href="http://www.elmundodejava.es/2009/12/05/algo-de-historia/" title="Algo de historia de Java&#8230;">Algo de historia de Java&#8230;</a></li><li><a href="http://www.elmundodejava.es/2009/12/09/los-mejores-libros-para-aprender-java/" title="Los mejores libros para aprender Java">Los mejores libros para aprender Java</a></li><li><a href="http://www.elmundodejava.es/2009/12/07/si-los-lenguajes-de-programacion-fuese-personas/" title="Si los lenguajes de programación fuesen personas">Si los lenguajes de programación fuesen personas</a></li><li><a href="http://www.elmundodejava.es/2009/12/13/tipos-de-variables-en-java/" title="Tipos de variables en Java">Tipos de variables en Java</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.elmundodejava.es/2009/12/05/comparacion-entre-algoritmos-de-ordenacion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
