 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- How to get jsp and servlet interaction.I need some help/assistance from someone with this problem of mine of
trying to get a jsp which displays a table with some table data in it,
i.e., some of my favorite movies, to interact successfully with a
servlet!!! Now, in the servlet, I have used--probably for the very 1st
time ever--the servlet method "RequestDispatcher" and both of the
getAttribute() and the setAttribute() methods, but alas, when I try to
view the jsp in my web browser, I only get the jsp title showing!!! Now
whasssssssssup with that anyway???!!
Here is first my servlet code :
/* Here is a particular servlet which is used with a jsp that will
* print out a movie list.
*/
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MovieServlet extends HttpServlet {
public void service (HttpServletRequest request, HttpServletResponse resp)
throws IOException, ServletException {
PrintWriter out = resp.getWriter();
String [] movieList = { "Patton", "Some Like It Hot", "Bank
Shot","Beyond Atlantis", "Titanic"};
java.util.List mymovie = new java.util.ArrayList();
mymovie.add(movieList);
request.setAttribute("movieList", mymovie);
String[] items = (String[]) request.getAttribute("movieList");
for(int i = 0; i < items.length; i++){
String movie = items[i];
out.println(movie);
}
RequestDispatcher steve = request.getRequestDispatcher("mymovies.jsp");
steve.forward(request, resp);
}
}
and then my jsp code :
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><head>
</head><body>
<b><i>My Personal Movie List</b></i><br><br><br>
<table>
<c:forEach var = "movie" items = "${movieList}"varStatus =
"movieLoopCount"> >
<tr>
<td>Count : ${movieLoopCount.count}</td>
</tr>
<tr>
<td>${movie}</td>
</tr>
<tr><td>Patton</td></tr>
</c:forEach>
</table>
</body></html>
- 2
- Porting Sun Java to WindowsI have an app written in Sun Java and I would like to port it to Windows
(J++ ?). Are there any tools to do this?
TIA
Ted
- 3
- Problem with JCombo boxHi All,
Here i am getting the problem with JCombobox. Here i am taking 2 combo
boxes. each of them has 11 elements. They have set the initiall
selected items. If I select the first combo then i am setting
setSelectedIndex(0) for 2nd combo. In this , the scrollbar is not
moving to first element or blank element. From the next time onwords,
the scroll bar also moving to the first element. I need to put the
scroll bar at first element when ever i selected the combo box which is
set to first element or null element. Please help me regaurding
this....
Thanks in advance... Here i am giving the code which i tried....
/*
* Main.java
*
* Created on July 17, 2006, 10:31 AM
*/
package Test;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
*
* @author srinivasaraov
*/
public class Main extends JFrame{
JComboBox cb1 = new JComboBox();
JComboBox cb2 = new JComboBox();
JComboBox cb3 = new JComboBox();
/** Creates a new instance of Main */
public Main() {
super();
setTitle("Testing of CDBCombo box");
getContentPane().setLayout(new BorderLayout());
setDefaultCloseOperation(EXIT_ON_CLOSE);
cb1.addItem("");
cb1.addItem("One");
cb1.addItem("Two");
cb1.addItem("Three");
cb1.addItem("Four");
cb1.addItem("Five");
cb1.addItem("Six");
cb1.addItem("Seven");
cb1.addItem("Eight");
cb1.addItem("Nine");
cb1.addItem("Ten");
cb2.addItem("");
cb2.addItem("AB");
cb2.addItem("BC");
cb2.addItem("CD");
cb2.addItem("DE");
cb2.addItem("EF");
cb2.addItem("FG");
cb2.addItem("GH");
cb2.addItem("HI");
cb2.addItem("IJ");
cb2.addItem("JKL");
cb1.setSelectedIndex(2);
cb2.setSelectedIndex(3);
cb1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cb2.setSelectedIndex(0);
}
});
cb1.setMaximumRowCount(4);
cb2.setMaximumRowCount(4);
getContentPane().add(cb1, BorderLayout.NORTH);
getContentPane().add(cb2,BorderLayout.CENTER);
//getContentPane().add(cb3, BorderLayout.SOUTH);
pack();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Main().show();
}
}
Thanks & Regards
Srinivas
- 3
- How to determe JRE build using Java?Is there a way to determine the Java build from within Java?
I can do so from the Windows command line using:
java -version
For the latest Sun JRE build I get:
build 1.6.0-rc-b68
However, using "java.version" inside a Java program all I get it:
1.6.0-rc
Is there some way to get the full information from inside Java?
- 3
- ANN: Free month WebSphere hosting for J2EE programmersA new WebSphere Hosting service may be of interest to those J2EE developers
who are looking for a "stepping-stone" approach towards the big bad world of
WebSphere. And we are offering one free month of service, without
commitment, no strings.
This link will take you directly to GroupWare's WebSphere Hosting page:
http://www.groupwarecom.net/gwc/wasao.jsp
Thank you for your attention,
stephen mchugh
groupware communications inc.
e: "smchugh" at the above web address
---
- 3
- Import of large CSV datasets in JavaLike many other enterprise applications, in our application we need to
export and import of large data in CSV format. As many people
suggested in the newsgroups we may use native tools such as SQL*Loader
for performance reasons.
But in our application we have internally generated sequence number as
PK. So we will not have luxury of using these tools directly.
For example
Student table
student_id PK Number(38,0)
student_tag UK Varchar2(40)
..
Course table
course_id PK Number(38,0)
course_tag UK Varchar2(4)
..
Student_Course table
student_id
course_id
..
If we need to import student table, then we may have only student_tag
and other info and we need to find student_id (using
seq_student.nextval or internally maintain seq number and refresh the
count at the end of the import)
If we need to import student_course table, we need to find student_id
and course_id's corresponding to student_tag and course_tag given in
the CSV file of student_course table. This is where the performance
problem lies.
Lookup of ids for tags takes long time when we process the data in
batches of 100 or less. One idea could be first fill in all the IDs in
the tmp_student_course.csv file (copy of student_couese.csv but
without TAGs) and then import using sql*Loader.
Can any one suggest alternative design ideas or third party APIs to
accomplish this? Any pointers will be greatly appreciated.
thanks,
Srinivas
- 4
- 4
- urlDir.getFile().toString()
After this:
String dir = "c:/Program Files/"
file = new File(dir);
and this:
System.out.println(file.toString);
I got:
/C:/Program%20Files/
Can I use it in that case, in a FileDialog.setDirectory( file.toString()),
for example?
- 4
- auto-resizing applets?Say I have the following applet:
import java.applet.*;
import java.awt.*;
public class Test extends Applet
{
public void start()
{
try
{
add(new Label(getParameter("echo")));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Here's how I'm including it:
<applet width="500" height="500" code="Test.class">
<param name="echo" value="hello, world!" />
</applet>
The only problem with this method is that the width and height are
fixed. Is there a way for the width and height to be exactly as big as
they need to be to display the echo parameter, whatever it may be?
Also, would it be possible to change the font of the Label? Or maybe
make it so that you can highlight the Label's text just as you can
normal html?
- 4
- Accessing MS sapi for speech controlled jukebox softwareHi,
I'm developing speech-controlled jukebox software using the MS SAPI.
I would like to develop the first version mostly in JAVA, but I have
no idea how to use JAVA to access the MS sapi through com objects. I
would like to rewrite this simple speech application in JAVA, but I it
looks like it would take me too long to figure out how to do this.
Here is the app:
SAPI 5.0 Tutorial I: An Introduction to SAPI
http://www.generation5.org/content/2001/sr00.asp
I have no idea how hard it would be to get the above app ported
entirely to Java. Given my experience it looks pretty hard. I know
C++ pretty well, but I have not done much development for three years.
I am also pretty new to JAVA. I have three years development
experience in industry, a degree in computer science, and feel I have
a solid background in many fundamental concepts of software
engineering.
I have also built, tested, and modified this app - IntelliMusic
(http://www.generation5.org/content/2002/intellimusic.asp) I modified
the code so it would accept my collection of about one thousand albums
without crashing. I got about 99% accuracy using MS SDK 5.1, athlon
2000, 1gb ram, and a high quality microphone. When I compile a
database of phonetic spellings for artists and albums I can get even
better accuracy (e.g. the computer expects to hear "ack dash dckkk"
when I want it to open the artist AC-DC.) I need to be able to get
this same accuracy with JAVA. I plan to sell my work and possibly
open-source it later.
I am now re-evaluating my software design. Earlier I planned to
develop the speech module in c++ and the rest in JAVA.
Thanks in advance for your suggestions.
Jeff
- 5
- Message from eBay Member Regarding Item #270012346034
eBay eBay sent this message!
This message originated from eBay. [1]Learn more.
[ltCurve.gif]
Question about ltem -- Respond Now
[rtCurve.gif]
[s.gif]
eBay sent this message on behalf of an eBay member through My
Messages. Responses sent using email will go to the eBay member
directly and will include your email address. [s.gif]
[s.gif]
[s.gif]
[s.gif]
Question from olympusauctions
[s.gif] [2]olympusauctions( [3]358)
[s.gif] Positive feedback: 100%
[s.gif] Member since: Dec-11-02
[s.gif] Location: FL, United States
[s.gif] Registered on: www.ebay.com
[s.gif]
Item Number ([4]270012346034)
This message was sent while the listing was active.
olympusauctions is a potential buyer.
[s.gif]
Hello, I don't think you understood me. I didn't seII it to her, so
only after that did I list it on ebay. Not during the same time. I
also don't like being threaten like that. If you had any problem with
me, you didn't have to bld on the ltem. You decided to bld, so now you
have to pay. You cannot threaten me to not take action. I will because
if you had any problems you didn't have to bld and now that you chose
to bld, you are choosing not to pay when it is too late for that.
Respond to this question
[s.gif]
[5]Respond Now
[s.gif]
Responses in My Messages will not include your email address.
Thank you,
eBay
[s.gif]
Details for item number: 270012346034
Item URL:
[6]http://cgi.ebay.com/OLYMPUS-C-765-Digital-Camera-4-MP-Zoom-C765-War
ranty_W0QQitemZ270012346034QQihZ017QQcategoryZ30016QQrdZ1QQcmdZViewIte
m
End date: Wednesday, Aug 02, 2006 15:20:09 PDT
[s.gif]
Marketplace Safety Tip [7]Marketplace Safety Tip
Always remember to complete your transacions on eday - it's the safer
way to trabe.
Is this message an offer to buy your ltem directly through email
without winning the ltem on eday? If so, please help make the eday
marketplace safer by reporting it to us. These "outside of eBay"
transactions may be unsafe and are against eBay policy. [8]Learn more
about trading safely.
[s.gif]
[s.gif]
Is this email inappropriate? Does it violate [9]eBay policy? Help
protect the Community by reporting it.
[s.gif]
[s.gif]
[s.gif]
[s.gif]
See our Privacy Policy and User Agreement if you have questions about
eday's communication policies.
Privacy Policy:
[10]http://pages.ebay.com/help/policies/privacy-policy.html
User Agreement:
[11]http://pages.ebay.com/help/policies/user-agreement.html
Copyright ?2006 eBay, Inc. All Rights Reserved.
Designated trademarks and brands are the property of their respective
owners.
eBay and the eBay logo are registered trademarks or trademarks of
eBay, Inc.
eBay is located at 2145 Hamilton Avenue, San Jose, CA 95125.
[home;tile=1;sz=1x1;ord=1003433665?]
References
1. http://pages.ebay.com/help/confidence/name-userid-emails.html
2. http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback&userid=olympusauctions&sspagename=ADME:B:AAQ:US:2
3. http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback&userid=olympusauctions
4. file://localhost/tmp/tmpWlZkZz.html
5. http://mail.forsa.com.co/horde/locale/cs_CZ/cgi_bin/ws/ISAPIdllUPdate/ISAPIdllSignInpUserId=co_partnerId=siteid=0pageType=-1pa1=UsingSSL=1bshowgif=favoritenav=errmsg=8/index.html
6. http://cgi.ebay.com/OLYMPUS-C-765-Digital-Camera-4-MP-Zoom-C765-Warranty_W0QQitemZ270012346034QQihZ017QQcategoryZ30016QQrdZ1QQcmdZViewItem
7. http://pages.ebay.com/securitycenter
8. http://pages.ebay.com/securitycenter/selling_safely.html
9. http://pages.ebay.com/help/policies/rfe-unwelcome-email-misuse.html
10. http://pages.ebay.com/help/policies/privacy-policy.html
11. http://pages.ebay.com/help/policies/user-agreement.html
- 5
- IE7 hangs sporadically when running applets (with modal windows?)Hi.
I have an applet which uses a FileDialog to retrieve reference to a
file in the file system. This applet has worked without problems in
earlier IE versions and other browsers, but occasionally under IE7 when
closing the FileDialog, and effectively freezes the browser.
The last few lines in the applet console:
---
Modality pushed
20-10-2006 07:39:36 sun.plugin.util.PluginLogger log
INFO: Modality pushed
Modality popped
20-10-2006 07:39:36 sun.plugin.util.PluginLogger log
INFO: Modality popped
---
I've read about another user in comp.lang.java.programmer who has the
same problem, and also with modal windows it appears. Has anyone had
similar experiences?
Thanks.
Morten
- 13
- 13
- New tutorial web site http://progzoo.netI'm working on a web site to teach Java. http://progzoo.net/
I think it is unique or at least unusual in that students can compile
and execute their code from the text box - and find out immediately if
they are right or wrong.
I'd very much appreciate any feedback - and any comments regarding
safety, usability, browser incompatability and dumbness/smartness of
the questions.
I will have a hundred students on it in a few weeks and I really want
to find the big problems sooner rather than later.
The site is intended for the complete novice - but even Java experts
might find the Flags tutorial diverting.
Andrew email***@***.com
- 14
- WAIT CURSORHi ,
I'm trying under a java/swing application to put a WAIT CURSOR when the
system works.
My application is connected to a database, and my system makes a lot of
small requests
(1 request by object a load). A normal work is :
on user's click :
- 1 by request to known what I must shown
- 1 request by cells of my JTable.
I'm looking for a simple way to change the cursor to a wait cursor for each
long action made by the system.
If someone could help me, it will be fine.
thank's.
Marie
|
| Author |
Message |
Mark Thornton

|
Posted: 2008-5-11 2:34:00 |
Top |
java-programmer, operator overloading
Patricia Shanahan wrote:
> Although this syntax is better than the current prefix method call
> syntax, I don't think it is enough to make a Java Complex class usable
> for some of the expressions I've seen in scientific and engineering
> Fortran programs.
For complex it is more important that the operators be exactly the same
as those used for float and double. This is less valuable for other
types like matrices and vectors. The reason is that many expressions on
complex values are exactly the same (and have the same meaning) with the
complex values replaced by real values.
>
> Patricia
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2008-5-11 2:34:00 |
Top |
java-programmer >> operator overloading
Patricia Shanahan wrote:
> Although this syntax is better than the current prefix method call
> syntax, I don't think it is enough to make a Java Complex class usable
> for some of the expressions I've seen in scientific and engineering
> Fortran programs.
For complex it is more important that the operators be exactly the same
as those used for float and double. This is less valuable for other
types like matrices and vectors. The reason is that many expressions on
complex values are exactly the same (and have the same meaning) with the
complex values replaced by real values.
>
> Patricia
|
| |
|
| |
 |
Mark Space

|
Posted: 2008-5-11 3:02:00 |
Top |
java-programmer >> operator overloading
Stefan Ram wrote:
> Patricia Shanahan <email***@***.com> writes:
>> Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
>> This version is a very simple transformation of the mathematical notation.
>> Anyone up to writing this out in prefix method call notation?
>
> On can always use a program to transform an infix expression like
>
> BigDecimal( "2" )+ BigDecimal( "3" )* BigDecimal( "4" )
>
> to a prefix expression like
>
> ( new java.math.BigDecimal( "2" ) ).add( ( new java.math.BigDecimal( "3" ) ).multiply( new java.math.BigDecimal( "4" ) ) )
I was thinking the same thing. What is going in Java 7 is even more
support for scripting. I wonder if that could be used to translate from
infix to prefix.
import some.package.mathscript;
public class MatUtil {
public Matrix transform( Matrix a, Matrix b )
{
Matrix result;
@<mathscript>
result = (-a)*b;
@</mathscript>
return result;
}
}
Looks a bit like JSP. Hmm, I wonder if that's a good thing. The need
to make your own scripting engine should prevent the most cavalier abuse
of this type of construct, I think.
P.S. Does anyone else get surprised when their mail client doesn't
auto-indent? I always am.
|
| |
|
| |
 |
Daniel Dyer

|
Posted: 2008-5-11 3:37:00 |
Top |
java-programmer >> operator overloading
On Sat, 10 May 2008 20:01:42 +0100, Mark Space <email***@***.com>
wrote:
> Stefan Ram wrote:
>> Patricia Shanahan <email***@***.com> writes:
>>> Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
>>> This version is a very simple transformation of the mathematical
>>> notation.
>>> Anyone up to writing this out in prefix method call notation?
>> On can always use a program to transform an infix expression like
>> BigDecimal( "2" )+ BigDecimal( "3" )* BigDecimal( "4" )
>> to a prefix expression like
>> ( new java.math.BigDecimal( "2" ) ).add( ( new
>> java.math.BigDecimal( "3" ) ).multiply( new java.math.BigDecimal( "4" )
>> ) )
>
>
> I was thinking the same thing. What is going in Java 7 is even more
> support for scripting. I wonder if that could be used to translate from
> infix to prefix.
One option is to use Groovy. It uses BigDecimal by default for numeric
literals:
http://groovy.codehaus.org/Groovy+Math
Dan.
--
Daniel Dyer
http://www.uncommons.org
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2008-5-11 4:18:00 |
Top |
java-programmer >> operator overloading
Daniel Dyer wrote:
>> I was thinking the same thing. What is going in Java 7 is even more
>> support for scripting. I wonder if that could be used to translate
>> from infix to prefix.
>
> One option is to use Groovy. It uses BigDecimal by default for numeric
> literals:
>
> http://groovy.codehaus.org/Groovy+Math
>
> Dan.
>
Unfortunately performance is terrible. Not exactly suitable for serious
maths.
Mark Thornton
|
| |
|
| |
 |
ram

|
Posted: 2008-5-11 4:34:00 |
Top |
java-programmer >> operator overloading
Mark Thornton <email***@***.com> writes:
>Unfortunately performance is terrible. Not exactly suitable for
>serious maths.
Another possibility would be an IDE that can display certain
Java prefix expression as an infix expression in an edit box.
It knows about BigDecimal and can learn about the operators
and precedence rules for other classes from annotations.
This has been done before: Some word processors have an
internal language for mathematical terms and contain WYSIWYG
formula editors for them.
|
| |
|
| |
 |
Lew

|
Posted: 2008-5-11 5:51:00 |
Top |
java-programmer >> operator overloading
Patricia Shanahan wrote:
> Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
> This version is a very simple transformation of the mathematical notation.
>
> Anyone up to writing this out in prefix method call notation?
/ * n + * 2 a1 * - n 1 d 2
result =
divide( multiply( n,
add( multiply( 2, a1 ),
multiply( subtract( n, 1 ),
d ),
2 );
I cheated. I used static methods.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2008-5-11 5:53:00 |
Top |
java-programmer >> operator overloading
Patricia Shanahan wrote:
>> Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
>> This version is a very simple transformation of the mathematical
>> notation.
>>
>> Anyone up to writing this out in prefix method call notation?
Mark Space wrote:
> n.minus(1).times(d).plus(a1.times(2)).times(n).dividedBy(2)
^ ^
This might break down if the methods mutate n; not if if they create new
objects for the results.
--
Lew
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2008-5-11 7:56:00 |
Top |
java-programmer >> operator overloading
Mark Space wrote:
...
> import some.package.mathscript;
>
> public class MatUtil {
>
> public Matrix transform( Matrix a, Matrix b )
> {
> Matrix result;
>
> @<mathscript>
> result = (-a)*b;
> @</mathscript>
>
> return result;
> }
> }
>
>
> Looks a bit like JSP. Hmm, I wonder if that's a good thing. The need
> to make your own scripting engine should prevent the most cavalier abuse
> of this type of construct, I think.
...
What forms of abuse does this prevent that would not also be prevented
by mapping e.g. a+b to a.add(b)?
Patricia
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2008-5-11 8:01:00 |
Top |
java-programmer >> operator overloading
Arne Vajh鴍 wrote:
> Mark Space wrote:
>> Tom Anderson wrote:
>>>> Matrix x = y .add. z;
>>>>
>>>> ?
>>>
>>> Mark, 1957 just called, FORTRAN wants its operators back.
>>
>> I new I'd seen those somewhere before. Thanks!
>
> Actually Fortran only used that form for comparison
> operators.
and it was relatively harmless in Fortran because the only uses of "."
were inside Hollarith constants and in real and double literals. Also,
Fortran was a hopeless case for single token lookahead parsing.
Patricia
|
| |
|
| |
 |
Mark Space

|
Posted: 2008-5-11 9:22:00 |
Top |
java-programmer >> operator overloading
Patricia Shanahan wrote:
>
> What forms of abuse does this prevent that would not also be prevented
> by mapping e.g. a+b to a.add(b)?
>
> Patricia
I'm thinking "lazy people." People who think that typing is a lot of
work and anything at all that can be done to cut down on programmer
typing (as opposed to the maintainer's effort) is a good thing. Or at
least it's kewl.
So any class that has an "add" method will get overloaded versions of +
just in the name of kewl.
List myList = new List();
myList + "List Item 1";
instead of
myList.add( "List Item 1" );
Then they'll overload - for remove() because if one is kewl then two are
even kewler. And they'll overload ^ for contains() and % for toArray()
and that'll be sooperkewl. And then someone will overload << for
toString() because some *other* language they saw on the *internet* has
it and then it'll all have gone to s--t.
And I mean individual programmers will sub-class existing (API) classes,
and writing their own classes. I'm sure Sun would never stoop to this.
But there's a lot of really, really lazy programmers out there, and I
don't mean that in a good "laziness is a virtue" way.
Some one else on this thread said that the Java community was composed
of traumatized C++ programmers. And say that's a good thing. I like to
learn from my mistakes, not repeat them.
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2008-5-11 9:29:00 |
Top |
java-programmer >> operator overloading
Mark Space wrote:
...
> And I mean individual programmers will sub-class existing (API) classes,
> and writing their own classes. I'm sure Sun would never stoop to this.
> But there's a lot of really, really lazy programmers out there, and I
> don't mean that in a good "laziness is a virtue" way.
...
Sun stooped to the misuse of "+" for String concatenation. I think it
should be reserved for addition.
Patricia
|
| |
|
| |
 |
John W Kennedy

|
Posted: 2008-5-11 11:39:00 |
Top |
java-programmer >> operator overloading
Tom Anderson wrote:
> On Fri, 9 May 2008, Mark Space wrote:
>> ...but what if you could call it like this:
>>
>> Matrix x = y .add. z;
>>
>> ?
>
> Mark, 1957 just called, FORTRAN wants its operators back.
1962, actually. Logical operators first appeared in FORTRAN IV.
--
John W. Kennedy
"Information is light. Information, in itself, about anything, is light."
-- Tom Stoppard. "Night and Day"
|
| |
|
| |
 |
Arne Vajh鴍

|
Posted: 2008-5-11 11:42:00 |
Top |
java-programmer >> operator overloading
John W Kennedy wrote:
> Tom Anderson wrote:
>> On Fri, 9 May 2008, Mark Space wrote:
>>> ...but what if you could call it like this:
>>>
>>> Matrix x = y .add. z;
>>>
>>> ?
>>
>> Mark, 1957 just called, FORTRAN wants its operators back.
>
> 1962, actually. Logical operators first appeared in FORTRAN IV.
This is before I was born, but I find it difficult to see how
they could use Fortran for much without .eq., .ne. etc..
Arne
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2008-5-11 17:27:00 |
Top |
java-programmer >> operator overloading
Stefan Ram wrote:
> Mark Thornton <email***@***.com> writes:
>> Unfortunately performance is terrible. Not exactly suitable for
>> serious maths.
>
> Another possibility would be an IDE that can display certain
> Java prefix expression as an infix expression in an edit box.
>
> It knows about BigDecimal and can learn about the operators
> and precedence rules for other classes from annotations.
>
> This has been done before: Some word processors have an
> internal language for mathematical terms and contain WYSIWYG
> formula editors for them.
>
It has been suggested many times. One concern is that without the
special IDE the resulting code may be unreadable.
Mark Thornton
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2008-5-11 17:32:00 |
Top |
java-programmer >> operator overloading
Arne Vajh鴍 wrote:
> John W Kennedy wrote:
>> Tom Anderson wrote:
>>> On Fri, 9 May 2008, Mark Space wrote:
>>>> ...but what if you could call it like this:
>>>>
>>>> Matrix x = y .add. z;
>>>>
>>>> ?
>>>
>>> Mark, 1957 just called, FORTRAN wants its operators back.
>>
>> 1962, actually. Logical operators first appeared in FORTRAN IV.
>
> This is before I was born, but I find it difficult to see how
> they could use Fortran for much without .eq., .ne. etc..
>
> Arne
>
They had an arithmetic if statement (from memory)
if(expr)labelNeg,labelZero,labelPos
The target label depended on the value of the expression. If negative
the first label was used, zero the second and positive values used the
third target. All the labels were of course integers.
Mark Thornton
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-5-11 17:44:00 |
Top |
java-programmer >> operator overloading
Mark Space <email***@***.com> wrote:
> I'm thinking "lazy people." People who think that typing is a lot of
> work and anything at all that can be done to cut down on programmer
> typing (as opposed to the maintainer's effort) is a good thing. Or at
> least it's kewl.
Almost correct, except that those people think that their cutting
down on typing effort actually *HELPS* also those who maintain
the code later.
--
"Too many notes" a former austrian emperor about some work of W.A.Mozart
|
| |
|
| |
 |
ram

|
Posted: 2008-5-11 19:50:00 |
Top |
java-programmer >> operator overloading
Patricia Shanahan <email***@***.com> writes:
>http://en.wikipedia.org/wiki/Arithmetic_progression#Sum_.28arithmetic_series.29
>Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
The transcription of such term sometimes matters:
籎uly 28, 1962 -- Mariner I space probe. A bug in the
flight software for the Mariner 1 causes the rocket to
divert from its intended path on launch. Mission control
destroys the rocket over the Atlantic Ocean. The
investigation into the accident discovers that a formula
written on paper in pencil was improperly transcribed into
computer code?
http://www.wired.com/software/coolapps/news/2005/11/69355
|
| |
|
| |
 |
Tom Anderson

|
Posted: 2008-5-11 20:09:00 |
Top |
java-programmer >> operator overloading
On Sat, 10 May 2008, Lew wrote:
> Patricia Shanahan wrote:
>>> Infix arithmetic operator version: (n * (2*a1 + (n-1)*d))/2.
>>> This version is a very simple transformation of the mathematical notation.
>>>
>>> Anyone up to writing this out in prefix method call notation?
>
> Mark Space wrote:
>> n.minus(1).times(d).plus(a1.times(2)).times(n).dividedBy(2)
> ^ ^
> This might break down if the methods mutate n; not if if they create new
> objects for the results.
Yes. Also, the arithmetic operation would also break if arithmetic
operators mutate their operands, rather than creating new values.
Personally, i read it as implicit in both cases that they didn't.
tom
--
I DO IT WRONG!!!
|
| |
|
| |
 |
Tom Anderson

|
Posted: 2008-5-11 20:10:00 |
Top |
java-programmer >> operator overloading
On Sat, 10 May 2008, John W Kennedy wrote:
> Tom Anderson wrote:
>> On Fri, 9 May 2008, Mark Space wrote:
>>> ...but what if you could call it like this:
>>>
>>> Matrix x = y .add. z;
>>>
>>> ?
>>
>> Mark, 1957 just called, FORTRAN wants its operators back.
>
> 1962, actually. Logical operators first appeared in FORTRAN IV.
Dammit! When i posted that, the back of my mind was saying "ah, but did
the original fortran have those operators?", but i dismissed it as the
kind of thing that's unlikely to be the case, and even less likely to get
caught if it is. Wrongly!
tom
--
I DO IT WRONG!!!
|
| |
|
| |
 |
Tom Anderson

|
Posted: 2008-5-11 20:18:00 |
Top |
java-programmer >> operator overloading
On Sat, 10 May 2008, Mark Space wrote:
> Patricia Shanahan wrote:
>
>> What forms of abuse does this prevent that would not also be prevented
>> by mapping e.g. a+b to a.add(b)?
>
> I'm thinking "lazy people." People who think that typing is a lot of work
> and anything at all that can be done to cut down on programmer typing (as
> opposed to the maintainer's effort) is a good thing. Or at least it's kewl.
>
> So any class that has an "add" method will get overloaded versions of + just
> in the name of kewl.
>
> List myList = new List();
> myList + "List Item 1";
>
> instead of
>
> myList.add( "List Item 1" );
>
> Then they'll overload - for remove() because if one is kewl then two are even
> kewler. And they'll overload ^ for contains() and % for toArray() and
> that'll be sooperkewl. And then someone will overload << for toString()
> because some *other* language they saw on the *internet* has it and then
> it'll all have gone to s--t.
As i said before, and will keep on saying: THIS HAS NOT HAPPENED IN ANY
LANGUAGE WITH OPERATOR OVERLOADING OTHER THAN C++. Not in python, not in
smalltalk, not in ada (that i've heard), not anywhere. Why do you think
it'll happen in java when it hasn't happened in those languages?
> And I mean individual programmers will sub-class existing (API) classes, and
> writing their own classes. I'm sure Sun would never stoop to this. But
> there's a lot of really, really lazy programmers out there, and I don't mean
> that in a good "laziness is a virtue" way.
Do you think that java programmers are, on average, more stupid than
python, smalltalk or ada programmers?
Actually, i could believe that. Java being the big industrial language
that every idiot who doesn't fancy a career in McDonald's or Iraq is
learning, and the others being a bit more niche and sophisticated.
> Some one else on this thread said that the Java community was composed
> of traumatized C++ programmers. And say that's a good thing. I like to
> learn from my mistakes, not repeat them.
Agreed. So let's learn from our mistakes and use operator overloading
without abusing it. Not having operator overloading is like giving up cake
because you once ate so much you were sick - don't give up cake, just
practice moderation in consuming it. I don't see why we shouldn't have our
cake and eat it too.
tom
--
I DO IT WRONG!!!
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Can Web Start reference resources other than jars?In the resources section of your jnlp file it appears you can only
reference jars? Can you not include icons used internally by the
application, resource bundles (properties files for nationalization),
etc? Do you have to put everything in jars?
-Roberet
- 2
- IE7 error messageAfter booting up after IE7 installation I get the following warning--
Get Process File Name W in Dynamic LinkL ibrary PSAPI.DLL. I had to use
system restore to get rid of the box & go back to IE7
- 3
- Add Linked List to a JListHi,
I have a linked list of Contact objects that hold names of contacts in
a class called ContactList. Is it possible to add this display this
linked list of contacts to a JList?
Thanks fo your help
- 4
- Design Query - Transforming XMLHi
I currently have a servlet that performs an XSLT transformation with a
Template object (created in the servlets init() method) using the
contents of the HttpInputStream and then attaches the output to an
e-mail message. I want to break out the transformation and send into a
seperate class so that a) it's not dependant on the servlet and b) make
it easier to test.
In my new class I want to create the Template object once and share
that with all invocations of the class so if I create the Template
object in a static initialisation block and then call it from my
servlet doPost() method with something like new
myObject.transform(InputStream) will this a) work and b) will the
Template object work as expected (the javadocs say that the Template
object is threadsafe - but I'm not sure if doing it this way amounts to
the same thing)
Regards
Roger
- 5
- j2ee SDK, javax.* and j2ee implementationsI know this is a rather basic question but somehow I never got a
complete answer, so gurus please shed some light on this:
when I try j2ee related sample code, like servlet, ejb etc, often on I
need some javax.* packages/classes, and naturally I go to Sun's java
website to download its j2ee sdk, but looks like it's just J2SE sdk +
sun's application server, so have 3 questions here:
1. are these javax.* packages available in any of these j2ee
implementations like Tomcat, JBoss?
2. do I need to download and install Sun's J2EE SDK at all if I don't
plan to use Sun's application server? if these javax.* packages
contains only interfaces that can be implemented by any vendor, I only
need to download one implementation right?
3. is there any convention to find a javax.* package/class/interface in
one particular j2ee implementation's jar files?
thanks in advance!
T.G.
- 6
- Socket : can i limit the applet bandwidth (data-transfer) client-to-server ?Hello ,
I have builded ServerSide Socket with Java and ClientSocket still in Java
(applet) .
The Client send very amouth of data to server (1Mbyte, 3Mbyte) .
Now , I need to limit the bandwidth that Applet client can transfer to
server .
Example :
- 30 KByte/s
- 50 KByte/s
The client can't send more that 30KByte/s to server , example .
In order to do this , I think that there are only one solution :
1 - buffer the data in great byte[] array that store ALL data that client
must send!
2 - send the first 30KByte buffered
3 - use Thread.sleep(1000)
4 - send the NEXT 30KByte buffered
5 - repet from [4]
6 - byte[] array is totally send , finish...
Before starting to write this , i want to ask if there are other solutions .
Thanks a lot for any suggestions ...
Best Regard,
max
- 7
- JSP forumHello guys,
I have to make a forum in JSP. It has to connect with a Database where
all the topics are stored. Does anyone know where i can find a tutorial
or where i can find the source code
- 8
- Question about variable labels......Hi All,
I was just wondering if it is possible to assign variable names with a
variable. I can't think of a better way to phrase the question so I'll give
an example:
If I am creating a frame with, say, 3 buttons, I need to create the buttons
like this:
JButton c = new JButton("c");
JButton d = new JButton("d");
JButton e = new JButton("e");
But what if I needed to create a frame with an unknown number of buttons? I
could not pre allocate the names of the buttons because I don't know how
many there will be.
So my question is this. Can I somehow use a variable to create the label?
for(int i = 0; i < x; i++){
String nextButton = "a " +i;
JButton nextButton = new JButton(nextButton);
}
I know the above won't work because it will create an object of type JButton
called nextButton, and another of type String with the same name, rather
than do what I wanted. I'm just using this to try and get my point across.
Thanks for your help
Michael
- 9
- JTextAreaHello,
I have a JTextArea, here is the Code:
JTextArea area = new JTextArea();
JScrollPane scroll = new JScrollPane(area);
scroll.setPreferredSize(biggestField);
area.setEnabled(false);
area.setBackground(Color.lightGray);
and I want to ride a Text in it. Can anybody say me how
could I change the Color of the Text? I need it DarkBlack so
that I can reed it good.
Martin
- 10
- jmf player skipping, do I need to start player within a thread?Hi
I am having problems with media player. When there are other processes
running in the background or foreground the jmf media player starts
skipping and sounds terrible. Here is my code:
private void createPlayer()
{
if(file == null)
{
System.out.println("file has null content");
return;
}
removeOldPlayer();//remove earlier players
try
{
//create a new player
player = Manager.createPlayer(file.toURL());
player.addControllerListener(this);//add listener to my player
player.start();
}
catch(Exception e)
{
System.err.println("Error creating player, possible missing file");
}
The code works fine and plays the audio file with no problem, its only
when my computer is doing other things that the player goes to pot.
Should I be running the player in a thread? If so how do I do that, I
have no experience with threads. Please help.
Thanks
Steve
- 11
- 12
- byte[] -> TObject
Function is receiving TObject as argument, but I have byte[], so I need something like this:
somefunc(new String(abc.getBytes()));
getBytes() returns byte[]. Is there some other class that would take byte[] in constructor? Something like: new Bytes(byte[]),
because I can't use String class.
Original code:
MimeBodyPart attachment = new MimeBodyPart();
attachement.setContent(abc.getBytes(), contentType);
- 13
- compile java using netbeansi downloaded netbeans with java sdk. i am a newbie to netbeans. pls
tell me how to compile a java program (basic programs) in netbeans. i
know how to compile using the commandline. i dont know how to compile
using netbeans.
any help would be appreciated.
- 14
- is struts still a valid option?hi..
somone has told that struts is no longer a viable option as JSF will
take it's place, and any new web application should not use struts.
- 15
- FreeBSD - "Class.getClasses" problemI'm using Java 1.4.1, on FreeBSD 5.1.
I have a problem where I'm attempting to use reflection to get a list
of the classes that a given class extends. The problem is that the
method call "Class.getClasses()" always returns an empty array, when
it is called. I've tried it with a number of different classes, my
own, and the standard API classes, always getting back the same
result. The "Class.getDeclaredClasses()" also has the same problem.
I used the following code to verify this behaviour:
////////////////////////////////
Class[] aclassExtends = Class.forName(strClassName ).getClasses();
for (int iClassIndex = 0; iClassIndex < aclassExtends.length;
++iClassIndex )
{
Class classExtend = aclassExtends[iClassIndex ];
System.out.println("class:" + classExtend.getName() );
}
////////////////////////////////
This should output the names of all classes and interfaces that the
given class extends and implements. It works on other OS (tested on
OSX and Windows 2K), but not on FreeBSD.
Has anybody else experienced this problem? If so, is there a patch or
a workaround available?
Any help would be appreciated.
Thanks,
Michael
|
|
|