roopa chakra

Greenhorn
+ Follow
since Jul 12, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by roopa chakra

Hi,

I need to display database table column values on JSP page whenever a user selects particular column name from Combo Box.I have dynamically populated column names in the Combo box. Below is the code.

<%
ResultSetMetaData rsmd = rs.getMetaData();

out.println("<SELECT>");
for(int i=1;i<=rsmd.getColumnCount();i++)
{
out.println("<OPTION>"+rsmd.getColumnName(i)+"<OPTION>");

}
out.println("</SELECT>");
%>
Now the problem is I am not getting how to display particular column values
based on the selected combobox value.

Could anybody give me an approach.
18 years ago
JSP
Thanks.I got the solution.
18 years ago
Here is my code.
I have taken small example
String lenearArr[]={"tom","brad","bread","lusy");
String searchArr[]={"lusy","brad"};


String midValue;
int mid;
int first=0;
int last=lenearArr.length;
for(int i=0;i<searchArr.length;i++)
{
while(first<last)
{
mid=(first+last)/2;
midValue=lenearArr[mid];
if(searchArr[i].equals(midValue))
{
System.out.println("the element"+searchArr[i]+" found "+mid);
break;
}

int cmp=(searchArr[i].compareTo(midValue));

if(cmp<0)
last=mid;

else
first=mid+1;
}
}

Could you tell me where I am wrong
18 years ago
Yes it is a home work Assignment.
18 years ago
Hi members,

I have two String Arrays: LinArray[]which has 10000 five lettered words
searchArray[] which has 1000 five lettered words

I have to perform a binary search to search 1000 elements in LinArray[].
I don't want to use built in Binary search method.

I know how to perform Binary search on primitives but not on strings.

Could anyone help me out? Thanks.
18 years ago
Thanks guys,

It was very helpful. I think I am closer to getting output.
This is my assignment. I cann't use vector only String Array.
I have to find length of the file so that I can specify array size.
I will use counter to get the length of the file.
18 years ago
Thanks Ameeral

But still I am not getting the output.

String linArray[i]=file.read();//Incompatible types.

This is what I wrote
try {
BufferedReader br=new BufferedReader(new FileReader("Fives.txt"));
while(br.readLine()!=null)
{
File inputFile=new File("Fives.txt");
int fileSize=(int)inputFile.length();
FileInputStream file=new FileInputStream(inputFile);
String linArray[]=new String[fileSize];
for(int i=0;i<5;i++)
{
linArray[i]=file.read();
System.out.println(linArray[i]);
}

file.close();
}

}
catch(IOException e){

System.out.println("I could not read the file");

}


please help.
18 years ago
Hi,

I have file called fives.txt which has
abcds
yngds
rteds
uoiyt
pouyi
'
'
'
'
upto 1000
How do I read these five lettered words and store it in a String array.
I tried in following program. file.read();doesn't work.

Can anyone help me with this.

try {
File inputFile=new File("Fives.txt");
int fileSize=(int) inputFile.length();
FileInputStream file=new FileInputStream(inputFile);
String linArray[]=new String[fileSize];
for(int i=0;i<5;i++)
{
linArray[i]=file.read();
System.out.println(linArray[i]);
}
file.close();
}

catch(IOException e){

System.out.println("I could not read the file");

}
18 years ago
Here is the question from K & b book :

import java.util.*;
class Roo{

public static void main(String args[])
{
Roo r=new Roo();
Object o=r.test();
}
object test(){}
//line 9
}

Which two of the following code fragments inserted at line 9 will not compile?

1)return null;
2)object t=new object();
return t;
3)int a[]=new int[2];
return a;
4) char[][] c=new char[2][2];
return c[0][1];
5)char [][]c=new char[2][2];
retutn c[1];
6)return 7;

Ans:4 and 6

I know that since 7 is primitive you cann't return. But I didn't understand ans 4 .
What is the difference between 4 & 5;

Can anybody help me to understand?

Thanks.
I Got it. Sorry to post here.
18 years ago
Hi,

Could anyone give me link to the Dan's mock exams?
I really appreciate your help.
18 years ago
Hi guys,

I am also preparing for SCJP1.4. I am planning to take exam on first week of august. Let me know your plans. Waiting for your reply.