Comparison oin java
i have this code that write a class Compare3 that provides a static method largest. Method largest should take three
Comparable parameters and return the largest of the three (so its return type will also be Comparable)
public class Compare3 {
public static Comparable largest(Comparable x, Comparable y, Comparable z)
if (x.compareTo(y) >= 0 && x.compareTo(z) >= 0)
return x;
else if (y.compareTo(x) >= 0 && y.compareTo(z) >= 0)
return y;
else
return z;
and then i want to Write a class Comparisons whose main method tests your largest method above.
(a) First prompt the user for and read in three strings, use your largest method to find the largest of the
three strings, and print it out. (It's easiest to put the call to largest directly in the call to println.) Note
that since largest is a static method, you will call it through its class name, e.g.,
compare3.largest(val1, val2, val3) and
(b) Add code to also prompt the user for three integers and try to use your largest method to find the
largest of the three integers. Does this work? If it does, it?s thanks to autoboxing, which is Java 1.6?s
automatic conversion of ints to Integers.
can someone give me a clue?.
i have something like this but am not sure
ublic class Comparisons
public static void main(String[] args)
if ( args.length < 3 ){
System.out.print("This program will find the largest ");
System.out.println("of 3 floating-point numbers");
System.out.println("entered as command-line arguments.");
System.out.println("To run this program, type:");
System.out.println(" java Compare3 num1 num2 num3");
System.out.print("using numeric values in place of ");
System.out.println("num1, num2, and num3.");
System.exit(x);
} // if
float number1 = Float.parseFloat(args[x]);
float number2 = Float.parseFloat(args[y]);
float number3 = Float.parseFloat(args[z]);
// Find the largest of all three numbers
// by comparing the third number to the
// largest of the first two:
if ( numberz > largest )
largest = numberz;
System.out.println("The largest of " + number1
+ ", " + number2
+ ", and " + number3
+ " is " + largest + ".");
it gives me a lot off errors
i DONT KNOW IF I'M DOING THE RIGHT THING,
To start with:
float number1 = Float.parseFloat(args[x]);
float number2 = Float.parseFloat(args[y]);
float number3 = Float.parseFloat(args[z]);What are these mysterious 'x', 'y', and 'z' variables doing here? It looks like you want the first, second, and third command line arguments, but throwing 'x', 'y', and 'z' symbols isn't going to make any magic happen. You need:
float number1 = Float.parseFloat(args[0]);
float number2 = Float.parseFloat(args[1]);
float number3 = Float.parseFloat(args[2]);
Next:
if ( numberz > largest )
largest = numberz;Again, where did this 'numberz' come from? Also, where did 'largest' come from?
You're just throwing code at a wall hoping some of it will stick and hoping for magic to happen.
i DONT KNOW IF I'M DOING THE RIGHT THINGClearly you're not. It isn't magic. It requires actual logical thinking.
Similar Messages
-
Hi, could anyone point me in the direction of some good articles online dealing with comparing the features of Java to other programming languages. Especially comparisons dealing with sound processing and GUIs.
Obviously i've been looking myself, but thought someone might happen to know some good links..
ThanksIf the docs say == could be false, so use equals, then == could be false, so use equals. The bug is in JAXB, for not following the docs, not in the VM. Even if == were required, it would be a bug in the implementation of the class, not in the VM.
-
Comparison of application server
Hello,
Can I get document comparisons of java application servers? I need performance comparison and pros and cons of following Application Servers
1) Oracle Application Server
2)BEA Weblogic (Oracle WebLogic)
3)Tomcat
4)Jboss
5)Resin
Regards,
SujnanHi,
Oracle Instant Portal is an out-of-the-box portal application built on top of OracleAS Portal. Although Oracle Instant Portal does feature a very different editing experience to pages built directly in OracleAS Portal, it is built using the same underlying components. Each instant portal consists of an OracleAS Portal Page group, set of pages, templates, navigation pages, custom item types and portlets.
Oracle Instant Portal does not support all the features of the flexible and powerful native OracleAS Portal product.
Regards,
Krishna -
Compare Java based reporting to OBIEE
Hello All,
Due to a lot of misconceptions, my current client thinks that a lot of their problems will be resolved by simply retiring OBIEE and write all the reports in Java.
Some requirements are unrealistic to ask from OBIEE and some are well...limitations.
The client has asked us to give him reasons why he still should be on OBIEE. Has anyone done a comparison of Java based reports and OBIEE (or any BI tool)?
Reasons why OBIEE stands out would also help.
Thanks all!!There are many, many reasons why to use OBIEE. One of the bigger reasons being you don't need to know anything about Java in order to build an Answer Report.
I've been asked a similar question in the past, to compare OBIEE versus Java based ADF. My response is that they have two completely different purposes.
--OBIEE is end-user/middle-user driven dashboards and ad-hoc analysis.
--Java/ADF is for power-users to pre-constructed reporting systems. (forgive me but I don't know the ad-hoc capabilities of Java/ADF)
If your client has full-time java resources to commit to the creation and maintenance of a Java environment, then by all means they should probably go that route. But keep in mind that as new uses want to see different data layouts and different data sets, your java team will quickly become overburdened.
OBIEE relieves the strain on the java (IT) team and allows end-users to drive reporting with the relatively occasional support by IT.
Yes, OBIEE does have limitations, but always keep in mind that a) It's an ad-hoc Dashboard framework and not an ad-hoc java framework which has much greater flexibility but requires much more technical expertise b) There is a major release of OBIEE (11g) just around the corner that is about to change the game in terms of how OBIEE can be used. You should have your client stay on board until they can at least see the new features.
Good luck and if you found this post useful, please award points!
Best regards,
-Joe -
Java.sql.Types.RAW
I know you can map a LONG RAW sql type to the java class oracle.sql.RAW when wrapping the java code in your pl/sql wrapper. The problem I am having is that within my java code I am returning result set and using reslutSetMetaData to determine if the column is a varchar or clob with a switch statment and a case comparison using java.sql.Types.whatever sql type i am looking for. I am running into a problem when trying to write a case statement for long raw columns. What would be the statement to use for this. Below is an example of the code.
int type = rsmd.getColumnType(1);
switch (type) {
case java.sql.Types.CLOB:
code to execute when CLOB type
break;
case java.sql.Types.Raw:
code to execute when LONG RAW type
break;
Thanks in advance,
Kevin
nulluser1330140 wrote:
...the return type which is defined inside DBMS_XDB_VERSION package
I think there are some threads somewhere that points to Oracle documentation somewhere that says that is not possible with JDBC.
I could certainly be mistaken however.
If I am not mistaken then you would need to
1. Wrap the call to that in another proc.
2. That proc extracts the result into something that is visible in the jdbc driver. -
Hello pepole,
Two questions to you all:
1) Where can i find a comparison between java collections, like arraylist, array, list, vector - comparison of performance, memory usage etc.
2) In case i need this collection type:
adding in the end, sorted, synchronaized is not really need.
what would you use ?
bye ,
Dor1. The 3rd edition of book "Thinking in Java" has smth about this.
(http://www.pythoncriticalmass.com/downloads/TIJ-3rd-edition4.0.zip). Also I found smth useful in book "Java Collections" by John Zukowski. But...I think the more interesting way is to write some comparative tests by youself ;-)
And...of course, read JavaDocs. -
Can JAVA import 3D Max Studio files?
I'm currently doing a research for my final project. The tittle is "Comparison Between JAVA 3D and Macromedia Director". Director can import 3D Max studio files, and i do not know whether can JAVA import 3D max Studio files? Pls help.... thanks
have a look at www.j3d.org , they have several different importers for 3d model file formats and might have one suitable..
-
Error while deploying entity javabean (CMP)
Hello,
I have a problem while I'm trying to deploy an entity javabean (with container managed persistance). I'm using JDeveloper 3.2.3 and 8.1.7.2 database.
Here is the error I get:
*** Executing deployment profile E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp.prf ***
*** Generating archive file E:\Xaris\JDeveloper\General\EJBs\EmpCmp\empcmp.jar ***
Compiling the project...done
Validating the profile...done
Initializing deployment...done
Scanning project files...done
Generating classpath dependencies...done
Generating archive entries table...done
*** Archive generation completed ***
*** Deploying the EJB to 8i JVM ***
EJB deployment argument list:
"E:\Program Files\Oracle\JDeveloper 3.2.3\java1.2\jre\bin\javaw"
"-DPATH=E:\Program Files\Oracle\JDeveloper 3.2.3\bin;E:\Program Files\Oracle\JDeveloper 3.2.3\java1.2\bin"
-classpath
"E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\aurora_client.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\javax-ssl-1_2.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\jasper.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjorb.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjapp.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjtools.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbj30ssl.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\aurora.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\sqlj\lib\translator.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\sqlj\lib\runtime.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\mts.jar;E:\Xaris\JDeveloper\General\EJBs\EmpCmp\classes;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\jdev-rt.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\jdbc\lib\oracle8.1.7\classes12.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\connectionmanager.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\javax_ejb.zip;C:\Program Fil
s\JavaSoft\JRE\1.3.1\lib\i18n.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\jaws.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\rt.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\sunrsasign.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\xmlparserv2.jar"
oracle.aurora.ejb.deployment.GenerateEjb
-u
harris
-p
harris
-s
sess_iiop://192.168.10.218:2481:WORK
-keep
-temp
TEMP
-descriptor
"E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp.xml"
-oracledescriptor
E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp_oracle.xml
-generated
"E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmpClient.jar"
"E:\Xaris\JDeveloper\General\EJBs\EmpCmp\empcmp.jar"
Reading Deployment Descriptor...done
Verifying Deployment Descriptor...done
Gathering users...done
Processing container managed persistence bean...done
Generating Comm Stubs.............................................done
Compiling Stubs...done
Generating Jar File...done
Loading EJB Jar file and Comm Stubs Jar file...done
Generating EJBHome and EJBObject on the server...
An exception occurred during code generation: null
*** Errors occurred while deploying the EJB to 8i JVM ***
*** Deployment completed ***
Can anyone help me understand where is the error?
Thanks in advance,
CharalamposVolker,
Let me try again (in the hope that this time you will understand
what I am saying).
"database embedded EJB container" and "EJB" are not the same thing.We are a little bit further in technology, so that we have no single Engine, single
Processor Systems any more.
Distribution over many computers (RAC) is done by Visigenic ORB (9i) or OC4J.
EJB Framework is for distribution of Business Logic or in your words of
Database Logic.
Oracle is abandoning the "database embedded EJB container".
Oracle is not abandoning EJB.Please step into technology and make a comparison of Java Stored
Procedures, look at the native compiler ncomp and try to figure out which
classes are important for Server Side software development.
Oracle recommends using OC4J as the EJB container.
Here is a recent post (from an Oracle employee and regular forum
participant) from the J2EE forum:
High number of http 404 errors from webcache
Here is a quote from that post:
starting from Oracle9i Release 2 Database EJBs are going to be desupported from database. EJBs can only be deployed in OC4J component of Oracle9iASAs far as I can see, it makes no sense to do that step.
I beleave, that this decision is very very short lived.
Unfortunately, my German is very poor -- I can only try to explainYou are right, I am a German.
things to you in English. Hopefully (if you are still not comprehending
what I am saying), some kind soul (who must have a better levelAmerican english is for everyone.
of reading and comprehension in English than you) will explain it
to you in your native tongue.I have understood, what you said!
So let me summarize:
Oracle is abandoning the database embedded EJB container.I don't beleave that! Is that OK!
By the way, something may have gotten lost in the translation, or
this may be just another example of your comprehension problem, but
what is the connection between the TowerJ JVM and the Oracle databasencomp has the same architecture as TowerJ native Compiler.
Ok?
embedded EJB container?
The very best of luck to you,Thanks a lot!
Avi +Volker! -
Trouble integrating SAX parser in a servlet for mini search engine.
OK, what I'm trying to do is to create a servlet that searches RSS feeds for titles that match the query, parses them using SAX, and writes them out to HTML, so that the user sees them. The problem is trying to get Ant to compile it since it appears that syntax errors are holding me back such as trying to use the out statements that are in the endElement and trying to find an algorithm that compares the search query with it's instance in the contents of the title tag. In other words, the search query seeks the contents in the title tag to see if there is an instance of the search query in it, so that it spits out the corresponding titles. Can someone please help me since I tried serching about this and came empty handed.
P.S.: I started working with servlets for about a month now, thus my knowledge is pretty much limited. Also, how would I go about in using multiple feeds for searching particular titles?
Here's the code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.URL;
import java.io.*;
import java.util.*;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.*;
public class SearchAndDeliver extends HttpServlet implements ContentHandler {
String queryString=null;
boolean inTitleElement;
boolean inLinkElement;
String title=null;
String link=null;
String comparison=null;
java.io.PrintWriter out = response.getWriter();
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts)
throws SAXException
if(localName.equals("title"))
title="";
inTitleElement=true;
if(localName.equals("link"))
link="";
inLinkElement=true;
public void endElement(String namespaceURI, String localName, String qualifiedName)
if(localName.equals("title"))
System.out.println(title);
inTitleElement=false;
if(localName.equals("link"))
System.out.println(link);
inLinkElement=false;
comparison=title.indexOf(queryString);
try
if(queryString.equals(comparison))
out.println("<a href=\""+link+"\""+">"+title+"</a><br>");
else
out.println(" Your search of "+queryString+" produced no results.");
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
public void characters(char[] text, int start, int length)
throws SAXException
if(inTitleElement)
title+=String.valueOf(text,start,length);
if(inLinkElement)
link+=String.valueOf(text,start,length);
public void setDocumentLocator(Locator locator) {}
public void startDocument()
throws SAXException
inTitleElement=false;
inLinkElement=false;
public void endDocument() {}
public void startPrefixMapping(String prefix, String uri) {}
public void endPrefixMapping(String prefix) {}
public void ignorableWhitespace(char[] text, int start,int length) throws SAXException {}
public void processingInstruction(String target, String data){}
public void skippedEntity(String name){}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
//XMLReader parser=new SAXParser();
XMLReader parser=XMLReaderFactory.createXMLReader();
queryString = request.getParameter("query");
response.setContentType("text/html");
out.println("<html>");
out.println("<head>");
out.println("</head>");
out.println("<body>");
out.println("<h2>Headlines from The New York Times Arts Section.</h2>");
try
parser.setContentHandler(this);
parser.parse("http://www.nytimes.com/services/xml/rss/nyt/Arts.xml");
catch(SAXException e)
//System.out.println(args[0]+" is not well formed");
System.out.println(e.getMessage());
catch(IOException e)
System.out.println("Due to an IOException, the parser could not check"+parser);//I don't know what to make of this as well.
// do-nothing methods
out.println("</body>");
out.println("</html>");
out.close();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
doPost(request,response);
}Here's the errors that I'm getting, and the rest are within the code since there's something wrong with the syntax and structure itself.
ant
Buildfile: build.xml
prepare:
compile:
[javac] Compiling 1 source file to C:\Program Files\Apache Software Foundati
on\Tomcat 5.0\webapps\searchanddeliver\build\WEB-INF\classes
[javac] C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\searc
handdeliver\src\SearchAndDeliver.java:20: cannot resolve symbol
[javac] symbol : variable response
[javac] location: class SearchAndDeliver
[javac] java.io.PrintWriter out = response.getWriter();
[javac] ^
[javac] C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\searc
handdeliver\src\SearchAndDeliver.java:48: incompatible types
[javac] found : int
[javac] required: java.lang.String
[javac] comparison=title.indexOf(querySt
ring);
[javac] ^
[javac] 2 errors -
How to combine sql.Date with sql.Time into one?
I have a database where I keep dates and times separately, and getting date only and time only out of a java.util.Date is no problem thanks to the classes java.sql.Date and java.sql.Time. However, I need to read these values back in, put them back together, and then do date comparisons with java.util.GregorianCalendar. I tried just adding the millisecond long values together but that didn't seem to work, and I've tried setting the year, month, date, hours, minutes and seconds individually into a GregorianCalendar but I haven't figured that out yet. Certain queries work out better keeping the date and time separate in the database and it takes less bytes than a timestamp, so please don't suggest I use a timestamp!
Thanks for your help!
StephenYou can add the milliseconds (ms), but you need to use just part of it. For this example, let X be one more than the maximum number of units in time and also the minimum number of units in date. If we were using hours instead of ms X would be 24.
t = total ms from time
d = total ms from date
T = new combined time
T = ((d / X) * X) + (T % X);Add (the date, rounded to the nearest day) and (the portion of time which is less than a day). -
Hello,
I am trying to establish a comparison of Java Management Extensions and Java Reflexion. What does JMX brings that "standard" reflexion cannot do? What is the difference between those two APIs and what would be a practical use case for them?
Thanks in advance,
Balteo.Well, firstly by defining an MBean you are restricting what classes and methods can be accessed - using reflection you could access any class and any method.
Secondly, you register in a central repository all your managed objects, so you don't have to keep track of all your objects yourself. This repository has namespaces so you can organise your objects.
Thirdly, JMX allows notification of events, rather than having to write your own custome event handling/routing etc.
Fourthly, JMX provides gauges, so that user defined limits can be put onto objects, and special events triggered when these limits are breached.
Using products such as Suns JDMK you can transparently remotely manage things, without having to write all that custom code yourself.
There may be more that I haven't thought of.
Don't really know of all of the uses of reflection, but JMX is very good for managing objects and managing and monitoring your system. If you look at JBoss they have a JMX micro kernal which loads all of the other parts of the app server, making it extremely flexible and easy to manage. -
Hi all,
can anybody tell me how to get the result of the following query by using cursor?
SELECT (SUBSTR(' ', 1,LEVEL*2)
|| t1.label) AS t1_label,
amount
FROM
(SELECT t1.label,
t1.ID,
t1.parent_id,
SUM(t2.turnover) AS amount
FROM t1,
t2
WHERE t2.t1_id = t1.id
AND t2.t1_id IN
(SELECT id
FROM t1
START WITH t1.ID = 2
CONNECT BY PRIOR t1.ID = t1.parent_id
GROUP BY t1.label, t1.ID, t1.parent_id
) t1
START WITH t1.ID = 2
CONNECT BY PRIOR t1.ID = t1.parent_id;...and the result:
t1_label amount
B11 11778.54
B121 19980.28
B1211 18842.77
B1212 25480.56
B122 18339.07
B12 23455.9
B13 20876.52Thanks,
Alex
Edited by: 860003 on Jun 9, 2011 1:30 AM
Edited by: 860003 on Jun 9, 2011 1:31 AM
Edited by: 860003 on Jun 9, 2011 1:31 AM860003 wrote:
Is not that i don't want to use hierarchy queries, but find others ways, tricks to reach the result needed. I just want to explore different ways that Oracle provides to resolve issues.Not a problem with that in principle.
Maybe using "loop, if-else, for" will provide us with an elegant way to get the result. However, a problem in principle with this. SQL and PL/SQL are not the same thing. Two separate and very different languages.
In PL/SQL, you can code both PL and SQL - so you can write source code of 2 different language and mix these. The PL/SQL parser is clever enough to figure out what is what and glues the code seamlessly and transparently together.
SQL is used to crunch SQL data. PL/SQL sucks at this in comparison (and Java/.Net sucks a heck of a lot worse at this). Cursor fetch loops? Bulk processing. Neat. But will always be slower than running that data crunching in SQL only.
That is why there is a simple maxim for performance in Oracle: Maximise SQL. Minimise PL/SQL.
Do not use PL/SQL to do what the SQL is perfectly able and capable of doing. The exception is when the processing is too complex for SQL to handle and you need the programming logic part of the PL/SQL language.
My question is how to use this cursor to get the value, fetch it and then get another value(ofc only for the children) and fetch it again so i can output it? I thing this can be achieve but don't know how.All SQLs (and anonymous PL/SQL) are parsed and cursors are created. A cursor is a basically a set of instructions (as seen via execution plans) of how to get the job done. Think of cursors as programs that are executed and output data.
So do you want t create a bunch of cursors (programs) and then call these from PL/SQL, consume their output, create/call new cursor programs and repeat?
Or do you want to create a single cursor program that does the job and outputs the required results?
Maximise SQL. Minimise PL/SQL. -
Arrays,bubblesort, and binary search
Hi I need help I have been working on this homework assignment for the past week and I can't seem to get it so if anyone can help me to figure out what is wrong I would reall grateful. Thanks ahead of time for the help.
Here is what is required for the assignment and also the errors I am getting.
Thanks!
Write a program that sorts an integer array in ascending order and checks whether an integer entered by user is in the array or not. Please follow the following steps to complete the assignment:
1. Declare and create a one-dimensional array consisting of 20 integers.
2. Read 20 integers from the user to initialize the array. Use input dialog box and repetition statement.
3. Build an output string containing the content of the array.
4. Sort the array in ascending order using bubbleSort( ) and swap( ) methods. Then, append the content of the sorted array to the output string.
5. Read an integer search key from the user;
6. Use binarySearch( ) method to check whether the search key is in the array or not. Then, append the search result to the output string.
7. Display the output string in a message box.
Here is my code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SortSearch {
public static void main (String args[])
String input, ouput;
int key;
int index;
int[] array=new int [20];
input=JOptionPane.showInputDialog("Enter 20 Numbers");
for(int counter=0; counter<array.length; counter++)
output+=counter+"\t"+array[counter]+"\n";
array(counter)=Integer.parseInt(input);
JTextArea inputArea=new JTextArea();
outputArea.setText(output);
public void bubblesort(int array2[] )
for(int pass=1; pass<array2.length; pass++){
for(int element=0; element<array2.length-1; element++){
if(array2[element]>array2[element+1])
swap(array2, element, element+1);
public void swap(int array3[], int first, int second)
int hold;
hold=array3[first];
array3[first]=array3[second];
array3[second]=hold;
public void actionPerformed(ActionEvent actionEvent)
String searchKey=actionEvent.getActionCommand();
int element=binarySearch(array, Integer.parseInt(searchKey) );
if(element!=-1)
output.setText("Found value in element " + element);
else
output.setText("Value not found ");
public int binary search(iny array2[], int key)
int low=0;
int high=array2.length-1;
int middle;
while(low<=high){
middle=(low + high)/2;
buildOutput(array2, low, middle, high);
if(key==array[middle] )
return middle;
else if(key<array[middle] )
high=middle-1;
else
low=middle+1
return-1
JOptionPane.showMessageDialog(null, outputArea);
System.exit(0);
} //end main
} //end class
Here is my errors
C:\java>javac SortSearch.java
SortSearch.java:27: illegal start of expression
public void bubblesort(int array2[] )
^
SortSearch.java:20: cannot resolve symbol
symbol : variable output
location: class SortSearch
output+=counter+"\t"+array[counter]+"\n";
^
SortSearch.java:22: cannot resolve symbol
symbol : variable counter
location: class SortSearch
array(counter)=Integer.parseInt(input);
^
SortSearch.java:25: cannot resolve symbol
symbol : variable output
location: class SortSearch
outputArea.setText(output);
^
SortSearch.java:25: cannot resolve symbol
symbol : variable outputArea
location: class SortSearch
outputArea.setText(output);
^
5 errorsI am still having problems.
Here is my code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SortSearch {
public static void main (String args[]){
String input, output;
int key;
int index;
int[] array=new int [20];
input=JOptionPane.showInputDialog("Enter 20 Numbers");
for(int counter=0; counter<array.length; counter++)
array(counter)=Integer.parseInt(input);
JTextArea outputArea=new JTextArea();
outputArea.setText(output);
public void bubblesort(int array2[] )
for(int pass=1; pass<array2.length; pass++){
for(int element=0; element<array2.length-1; element++){
if(array2[element]>array2[element+1])
swap(array2, element, element+1);
} //end inner for
} //end outer for
} //end bubblesort
public void swap(int array3[], int first, int second)
int hold;
hold=array3[first];
array3[first]=array3[second];
array3[second]=hold;
} //end swap
public void actionPerformed(ActionEvent actionEvent)
String searchKey=actionEvent.getActionCommand();
int element=binarySearch(array, Integer.parseInt(searchKey) );
if(element!=-1)
outputArea.setText("Found value in element " + element);
else
outputArea.setText("Value not found ");
} //end actionperformed
JOptionPane.showMessageDialog(null, outputArea,"Comparisons");
} //end classHere is my errors
C:\java>javac SortSearch.java
SortSearch.java:57: <identifier> expected
JOptionPane.showMessageDialog(null, outputArea,"Comparisons");
^
SortSearch.java:57: cannot resolve symbol
symbol : class showMessageDialog
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, outputArea,"Comparisons");
^
SortSearch.java:19: cannot resolve symbol
symbol : method array (int)
location: class SortSearch
array(counter)=Integer.parseInt(input);
^
SortSearch.java:49: cannot resolve symbol
symbol : variable array
location: class SortSearch
int element=binarySearch(array, Integer.parseInt(searchKey) );
^
SortSearch.java:52: cannot resolve symbol
symbol : variable outputArea
location: class SortSearch
outputArea.setText("Found value in element " + element);
^
SortSearch.java:54: cannot resolve symbol
symbol : variable outputArea
location: class SortSearch
outputArea.setText("Value not found ");
^
6 errors
Thanks ahead of time I still don't understand the stuff so I sometime don't understand what my errors are telling me so that is why I ask for your help so that maybe it will help make sense. -
Can anyone share some thoughts on how IBM's use of Local Service Bus compare with what JBI is providing..
The concept of Local Service Bus from IBM, at first glance, appears to be somewhat similar to
JBI. However, the lack of details on Local Service Bus and the proprietary nature of its architecture
makes it hard to do a comparison.
Java Business Integration 1.0 is close to finalization and has been a community effort with the likes
of Apache, Iona, Jboss, Oracle, SAP, SeeBeyond, Sonic, Sun, Tibco and others (http://jcp.org/en/jsr/detail?id=208). It would be good to have IBM participate in the standardization effort too.
To see how JBI works, go to http://java.sun.com/integration and download the early access version.
There is a technical article at
http://java.sun.com/integration/reference/techart/jbi/ that describes how to develop a service engine component for JBI. More to follow. -
Is it possible to capture audio or video in JavaFX. I'd like to record live streams :)
Thanks for the links.
It's (again) disappointing to see that AV capture will be ready in Q4 2013 when all other major platforms have it already (some for years now).
To continue in my rant, JavaFX brings nothing new - Oracle is just catching up with mainstream. I don't really get it. The whole JRE needs major redesign - new APIs and everything united and with flat hierarchy. I'd love to use it (and I'll have to if I want to develop UIs in Java), but it's not really innovative product. I know this has to be discouraging thing to hear for the JavaFX team, but it's the truth.
JRE should contain, rich multimedia APIs, UI framework and 2D/3D scenegraph library. Look at what Google/Apple have been able to accomplish across their platforms in no time, in comparison with Java...
Btw the last link points to some DB issue with Canadian date/time format...
I voted up the issue, others should do the same to get it in earlier than in one and half year - http://javafx-jira.kenai.com/browse/RT-3458 By that time, HTML5 will have it, cross-platform (even on cellphones).
To be fair, I have to add that Java Sound API is included in the JRE and one can use it for audio capture and playback.
Edited by: user10869786 on Apr 24, 2012 12:31 PM
Maybe you are looking for
-
Can we print header text in a tabular format
Hi, In the below program i need the text type payment history in a proper format.so plz help me regarding this. this a just a test program,you just execute this program.its running. i am feching the text payment history using the function module READ
-
Can you transfer one ITunes library to a different computers ITunes?
The Computer I have, has all my music from itunes on it but it keeps crashing. But i own a mac book which is perfectly fine. Can i transfer my whole itunes library off of my broken cpu and transfer it to my mac? It would be much helpful if you could
-
I have the Easy System Cleaner. It worked through Internet Explorer. But when it comes to Mozilla Foxfire. It stops. The message is: error executing sql. Error 26. File opened that is not a database file "select[sql] from sqlite_master where [type]="
-
Why isn't my browser supported?
One of the challenges of delivering desktop-quality software inside a browser is, well, the browser itself. For more details on our approach to browser support, its challenges, etc. please see the posting on the Acrobat.com blog. http://blogs.adobe.c
-
I cannot get my iPod touch to go into landscape mode either with the calculator or with my Persons Qmix software app. I have no problems on the iPhone or iPad, but it has all of a sudden stopped working. I tried rebooting the OS, a reset and the orie