Ignorar Array Indefinido

Boa Noite Pessoal!

Estou com um pequeno problema…

Estou com um sisteminha em java que resgata noticias em um banco de dados e exibe cada registro dentro de um Array… Cada item desse array é exibido sequencialmente com recursos de Fade In e Fade Out…

Todavia, o problema é que quando removo um registro do database, o mesmo continua sendo procurado pelo Java…

Além disso gostaria que ele fizesse a leitura de forma decrescente… para que as noticias mais recentes fossem exibidas primeiro…

Exemplo no site: http://www.vjmi.com.br/2009/Noticias.asp

Exemplo:

fcontent[0] = “noticia 1”
fcontent[1] = “noticia 2”
fcontent[2] = “noticia 3”
fcontent[3] = “noticia 4”

Acontece que estou gerando os itens do array de acordo com os registro do banco…
fcontent[<%=nt2(“id”)%>]=“conteudo”;

Aí quando removo um registro o java procura a sequencia…

Eu gostaria de saber se tem como ele ignorar a leitura de um item dentro do array quando ele inexiste?

Olha meu código como está…

&lt;!-- #include file="config.inc" --&gt;&lt;%session.LCID=1046%&gt;&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;VJ | MCE&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;style type="text/css"&gt;
&lt;!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F2F2F2;
}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" leftmargin="0" marginwidth="0"&gt;
<a  target="_parent"><img     /></a>
&lt;script type="text/javascript"&gt;

/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 3500; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(221,91,94); // end color (red, green, blue)

var fcontent=new Array();
begintag='&lt;div style="font: normal 12px trebuchet MS; padding: 15px;"&gt;'; //set opening tag, such as font declarations
&lt;%
Set nt2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
nt2.Open &quot;SELECT * FROM noticias ORDER BY id ASC&quot;, DB
Do while not nt2.Eof
Titulo = nt2(&quot;titulo&quot;)
Chamada = nt2(&quot;chamada&quot;)
Data = nt2.fields(&quot;data&quot;)	
Dim dbX2
if dbX2 &lt;&gt; currdate then
dbX2 = currdate
Session.LCID = 1046
end if	
%&gt;
fcontent[&lt;%=nt2("id")%&gt;]="<a  target='_parent' >&lt;%Response.Write Titulo%&gt;</a><br><br>&lt;%Response.Write Chamada%&gt;<br><br>&lt;span class='datas'&gt;[&lt;%Response.Write Data%&gt;]&lt;/span&gt;";
&lt;%
nt2.Movenext
Loop
%&gt;
closetag='&lt;/div&gt;';

var fwidth='250px'; //set scroller width
var fheight='150px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=1;


/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index&gt;=fcontent.length)
    index=1
  if (DOM2){
    document.getElementById(&quot;fscroller&quot;).style.color=&quot;rgb(&quot;+startcolor[0]+&quot;, &quot;+startcolor[1]+&quot;, &quot;+startcolor[2]+&quot;)&quot;
    document.getElementById(&quot;fscroller&quot;).innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById(&quot;fscroller&quot;).getElementsByTagName(&quot;A&quot;);
  if (obj.length&gt;0){
    for (i=0;i&lt;obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step&gt;&lt;=maxsteps) {	
    document.getElementById(&quot;fscroller&quot;).style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout(&quot;colorfade(&quot;+step+&quot;)&quot;,stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById(&quot;fscroller&quot;).style.color=&quot;rgb(&quot;+endcolor[0]+&quot;, &quot;+endcolor[1]+&quot;, &quot;+endcolor[2]+&quot;)&quot;;
    setTimeout(&quot;changecontent()&quot;, delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i&lt;3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff &gt; 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return (&quot;rgb(&quot; + newcolor[0] + &quot;, &quot; + newcolor[1] + &quot;, &quot; + newcolor[2] + &quot;)&quot;);
}

if (ie4||DOM2)
  document.write('&lt;div id="fscroller" style="width:'+fwidth+';height:'+fheight+'"&gt;&lt;/div&gt;');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent

&lt;/script&gt;
&lt;div id="fscroller" style="width: 250px; height: 150px; color: rgb(221,91,94);"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

Pelo que entendi você está obtendo um NullpointerException tentando ler uma posição do Array sem instância (nula)…Se for o caso…Faça um teste para verificar se a tal posição não for nula (array[i]!=null)…Não sei se entendi direito…

De qualquer forma, acho que o mecanismo que devolve este array está mal implementado…

Então… se está mal desenvolvido eu não sei… pois sou totalmente leigo em Java… meu conhecimento é baseado na leitura dos códigos…
A única coisa que preciso é que ele ignore a array nula e passe para a próxima automaticamente…

Será que podes me ajudar?

Somebody to help me?!

O.o

onde dá o erro ?

tenta fazer um if tipo

if(array.size()==0) System.out.println("Ih é null");

Legal meu caro… a solução está próxima…
mas ao invés de retornar o “Ih é null” eu gostaria que ele lêsse o próximo item do array… entende?

Exemplo:

array[0]=“zero”
array[1]=“um”
array[3]=“tres”
array[4]=quatro"

Ele fica procurando o item “array[2]” e ao invés de retornar o print q vc sugeriu queria q ele lêsse o array[3]

Tks…

na próxima interação ele vai ler o próximo…

		String[] array = new String[10];   
		array[0]=&quot;zero&quot;; 
		array[1]=&quot;um&quot;; 
		array[3]=&quot;tres&quot;; 
		array[4]=&quot;quatro&quot;;
		for (int i = 0; i &lt; array.length; i++) {
			if(array[i]==null)
			System.out.println(&quot;iH é null&quot;);
		}

Sim…Faz exatamente o que eu disse…Quando você percorre o array, verifica antes se a posição não é nula ( if(array[i]!=null) )…

Uma pergunta…

Vc não pode usar outra estrutura de dados??? Tipo um List???

abraço,

E como eu faria isso? Pois não tenho o domínio de Java.

Grato!