<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
>
	<channel>
		<title>Dudas de Programacion &#187; Tag: posicion - Recent Posts</title>
		<link>http://www.dudasprogramacion.com/tags/posicion</link>
		<description>Dudas sobre lenguajes y apis de programación</description>
		<language>en-US</language>
		<pubDate>Tue, 07 Feb 2012 21:52:53 +0000</pubDate>
		<generator>bbpress 1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.dudasprogramacion.com/search.php</link>
		</textInput>
		<atom:link href="http://www.dudasprogramacion.com/rss/tags/posicion" rel="self" type="application/rss+xml" />

		<item>
			<title>fiurer87 on "Una duda con arreglos(basico)"</title>
			<link>http://www.dudasprogramacion.com/topic/una-duda-con-arreglosbasico#post-551</link>
			<pubDate>Fri, 23 Jul 2010 14:59:38 +0000</pubDate>
			<dc:creator>fiurer87</dc:creator>
			<guid isPermaLink="false">551@http://www.dudasprogramacion.com/</guid>
			<description><p>en caso de que quieras crear una funcion que busque un elemento y retorne el indice es mas sencillo.<br />
Esta funcion retornara -1 si es que no hallo el elemento, en caso de que existan el elemento en mas de una posicion solo tomara en cuenta la primera coincidencia y retorara el indice-posicion donde se hallo el elemento.</p>
<pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> posicionElemento<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arreglo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>arreglo.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
       <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arreglo<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span>x<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> i<span style="color: #339933;">;</span>
   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;</pre></description>
		</item>
		<item>
			<title>fiurer87 on "Una duda con arreglos(basico)"</title>
			<link>http://www.dudasprogramacion.com/topic/una-duda-con-arreglosbasico#post-550</link>
			<pubDate>Fri, 23 Jul 2010 14:53:33 +0000</pubDate>
			<dc:creator>fiurer87</dc:creator>
			<guid isPermaLink="false">550@http://www.dudasprogramacion.com/</guid>
			<description><p>Buenas sugerencias.<br />
Pero hay que preguntarse que pasa si el elemento que buscas existe en mas de una posicion, en tal caso deberias imprimir todas las posiciones donde se encuentra.</p>
<p>Aquí la mía.</p>
<pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buscarElemento<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">boolean</span> estado <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>arreglo.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arreglo<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Posicion: &quot;</span><span style="color: #339933;">+</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         estado <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>estado<span style="color: #009900;">&#41;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Elemento no encontrado&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;</pre></description>
		</item>
		<item>
			<title>Torres on "Una duda con arreglos(basico)"</title>
			<link>http://www.dudasprogramacion.com/topic/una-duda-con-arreglosbasico#post-549</link>
			<pubDate>Fri, 23 Jul 2010 06:45:23 +0000</pubDate>
			<dc:creator>Torres</dc:creator>
			<guid isPermaLink="false">549@http://www.dudasprogramacion.com/</guid>
			<description><p>Buenas,</p>
<p>como te comenta garusis el problema es que tenías dentro del bucle la línea que imprimía por pantalla.</p>
<p>No se si estás practicando o necesitas usar los arreglos para algo más, pero por informarte que sepas que existe una clase de utilidades en Java para el manejo de arreglos.</p>
<p><a href="http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/util/Arrays.html" rel="nofollow">http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/util/Arrays.html</a></p>
<p>Y ya trae unos métodos para la búsqueda optimizados, un ejemplo de lo que tu quieres hacer hecho con esta clase de utilidades:</p>
<pre class="java" style="font-family:monospace;">&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Arrays</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Prueba <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> listaEnteros <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">28</span>, <span style="color: #cc66cc;">49</span>, <span style="color: #cc66cc;">88</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">336</span>, <span style="color: #cc66cc;">500</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    	<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span>listaEnteros<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">binarySearch</span><span style="color: #009900;">&#40;</span>listaEnteros, <span style="color: #cc66cc;">88</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;</pre></description>
		</item>
		<item>
			<title>garusis on "Una duda con arreglos(basico)"</title>
			<link>http://www.dudasprogramacion.com/topic/una-duda-con-arreglosbasico#post-548</link>
			<pubDate>Fri, 23 Jul 2010 02:13:20 +0000</pubDate>
			<dc:creator>garusis</dc:creator>
			<guid isPermaLink="false">548@http://www.dudasprogramacion.com/</guid>
			<description><p>pues... en tu lugar, eliminaria el else del ciclo... si te fijas, es totalmente innecesario, ya que si no entra por el if, el valor de enc seguira siendo false. si es necesario que muestre el mensaje de que el elemento no fue encontrado, entonces puedes agregar un if al final comprobando si lo encontro o no... algo asi:</p>
<pre class="java" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buscarElem<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #000066; font-weight: bold;">boolean</span> enc <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>arreglo.<span style="color: #006633;">length</span> <span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">38</span><span style="color: #339933;">;&amp;</span>#<span style="color: #cc66cc;">38</span><span style="color: #339933;">;</span> <span style="color: #339933;">!</span>enc<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">       <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arreglo<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span>x<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">       <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">           enc <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">           <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;elemento encontrado:&quot;</span><span style="color: #339933;">+</span> x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">       <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   i<span style="color: #339933;">++;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>enc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">       <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;elemento no encontrado:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre></description>
		</item>
		<item>
			<title>saintmauricioxd on "Una duda con arreglos(basico)"</title>
			<link>http://www.dudasprogramacion.com/topic/una-duda-con-arreglosbasico#post-547</link>
			<pubDate>Thu, 22 Jul 2010 23:42:59 +0000</pubDate>
			<dc:creator>saintmauricioxd</dc:creator>
			<guid isPermaLink="false">547@http://www.dudasprogramacion.com/</guid>
			<description><p>Bueno stoy empezando con arreglos y tengo una duda con este codigo:</p>
<pre class="java" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buscarElem<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #000066; font-weight: bold;">int</span> res<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #000066; font-weight: bold;">boolean</span> enc <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>arreglo.<span style="color: #006633;">length</span> <span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">38</span><span style="color: #339933;">;&amp;</span>#<span style="color: #cc66cc;">38</span><span style="color: #339933;">;</span> <span style="color: #339933;">!</span>enc<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arreglo<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span>x<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                enc <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                res<span style="color: #339933;">=</span>x<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;elemento encontrado:&quot;</span><span style="color: #339933;">+</span> res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                  enc <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;elemento no encontrado.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                i<span style="color: #339933;">++;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #009900;">&#125;</span></div></li></ol></pre>
<p>esto busca un elemento en el arreglo y lo devuelve, funciona correctamente pero lo q no logro solucionar esq digamos cuando encuentra un elemento en la posicion 6 me imprime para los indices del 0-4 "elemento no encontrado." y el 5 devuelve el numero, eso quiero q me notifique pero sin que repita tantas veces los indices "elemento no encontrado" al recorrer la lista, alguna sugerencia es bienvenida muchas gracias de antemano.
</p></description>
		</item>
		<item>
			<title>fiurer87 on "¿Obtener las posición del cursor en un JTextField en Java?"</title>
			<link>http://www.dudasprogramacion.com/topic/%c2%bfobtener-las-posicion-del-cursor-en-un-jtextfield-en-java#post-401</link>
			<pubDate>Sun, 16 May 2010 15:53:14 +0000</pubDate>
			<dc:creator>fiurer87</dc:creator>
			<guid isPermaLink="false">401@http://www.dudasprogramacion.com/</guid>
			<description><p>Seria ideal que los administradores del foro habiliten de una vez el [CODE], o algun medio para subir el codigo. :)
</p></description>
		</item>
		<item>
			<title>fiurer87 on "¿Obtener las posición del cursor en un JTextField en Java?"</title>
			<link>http://www.dudasprogramacion.com/topic/%c2%bfobtener-las-posicion-del-cursor-en-un-jtextfield-en-java#post-400</link>
			<pubDate>Sun, 16 May 2010 15:51:16 +0000</pubDate>
			<dc:creator>fiurer87</dc:creator>
			<guid isPermaLink="false">400@http://www.dudasprogramacion.com/</guid>
			<description><p>Hola,</p>
<p>el metodo getCaretPosition() devuelve la posicion donde se encuentra el (&#124;) en el texto, esta posicion es un entero que va desde 0 hasta el ultimo caracter de lo que esta escrito dentro del JTEXTAREA. ademas existe el metodo insert(String s, int pos), que escribe el texto s en la posicion pos, la posicion la obtendremos con el primer metodo mencionado. Bueno te paso de una vez el codigo, para que lo pruebes, espero sea de ayuda :). Saludos</p>
<p>=========================================================<br />
/* Inserta la palabra NUEVO, en la posicion del &#124; dentro de JTextArea<br />
   @author Luis Roberto Perez Rios*/</p>
<p>import javax.swing.JFrame;<br />
import javax.swing.JTextArea;<br />
import javax.swing.JButton;<br />
import java.awt.event.ActionEvent;<br />
import java.awt.event.ActionListener;<br />
import java.awt.BorderLayout;</p>
<p>public class Marco extends JFrame{<br />
    private JTextArea area;<br />
    private JButton boton;</p>
<p>    public Marco(){<br />
        super(&#34;Insertar&#34;);<br />
        setLayout(new BorderLayout());<br />
        setSize(200,200);<br />
        area = new JTextArea();<br />
        boton = new JButton(&#34;Insertar NUEVO&#34;);<br />
        boton.addActionListener(new ActionListener(){<br />
            public void actionPerformed(ActionEvent ae){<br />
                area.insert(&#34;NUEVO&#34;, area.getCaretPosition());<br />
            }<br />
        });</p>
<p>        add(area, BorderLayout.CENTER);<br />
        add(boton, BorderLayout.SOUTH);<br />
    }</p>
<p>    public static void main(String[] arg){<br />
        Marco marco = new Marco();<br />
        marco.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />
        marco.setVisible(true);<br />
    }<br />
}
</p></description>
		</item>
		<item>
			<title>Torres on "¿Obtener las posición del cursor en un JTextField en Java?"</title>
			<link>http://www.dudasprogramacion.com/topic/%c2%bfobtener-las-posicion-del-cursor-en-un-jtextfield-en-java-1#post-318</link>
			<pubDate>Thu, 11 Feb 2010 16:48:03 +0000</pubDate>
			<dc:creator>Torres</dc:creator>
			<guid isPermaLink="false">318@http://www.dudasprogramacion.com/</guid>
			<description><p>Buenas, </p>
<p>JTextField.getCaretPosition() te devuelve un entero con la posición el cursor.</p>
<p><a href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getCaretPosition%28%29" rel="nofollow">http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getCaretPosition%28%29</a></p>
<p>Un saludo!
</p></description>
		</item>
		<item>
			<title>Edmond on "¿Obtener las posición del cursor en un JTextField en Java?"</title>
			<link>http://www.dudasprogramacion.com/topic/%c2%bfobtener-las-posicion-del-cursor-en-un-jtextfield-en-java-1#post-315</link>
			<pubDate>Tue, 09 Feb 2010 17:48:53 +0000</pubDate>
			<dc:creator>Edmond</dc:creator>
			<guid isPermaLink="false">315@http://www.dudasprogramacion.com/</guid>
			<description><p>Ejemplo:<br />
Suponiendo el cursor sea &#34;&#124;&#34;<br />
En el JTexlField (en ejecución) : &#34;No sé que&#124; todo&#34;<br />
Quisiera sabes que desde un JButton se agrege cualquier text en esa posición, suponiendo que el JButton agregue &#34;OOO&#34;<br />
El JTextField quedaría: &#34;No sé queOOO todo&#34;<br />
Espero su ayuda...<br />
saludos
</p></description>
		</item>
		<item>
			<title>Edmond on "¿Obtener las posición del cursor en un JTextField en Java?"</title>
			<link>http://www.dudasprogramacion.com/topic/%c2%bfobtener-las-posicion-del-cursor-en-un-jtextfield-en-java#post-314</link>
			<pubDate>Tue, 09 Feb 2010 17:47:14 +0000</pubDate>
			<dc:creator>Edmond</dc:creator>
			<guid isPermaLink="false">314@http://www.dudasprogramacion.com/</guid>
			<description><p>Ejemplo:<br />
Suponiendo el cursor sea &#34;&#124;&#34;<br />
En el JTexlField (en ejecución) : &#34;No sé que&#124; todo&#34;<br />
Quisiera sabes que desde un JButton se agrege cualquier text en esa posición, suponiendo que el JButton agregue &#34;OOO&#34;<br />
El JTextField quedaría: &#34;No sé queOOO todo&#34;<br />
Espero su ayuda...<br />
saludos
</p></description>
		</item>

	</channel>
</rss>

