 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- java slows down suddenly?hi..
for some reason the java in our aix suddeny slowed down, meaning only
application using it (like tomcat 4.18) were extremly slow. (tomcat was
listening on port 18080)
tomcat was laucnehd by the a wrapper who reported messages like pingin
jvm and not getting a response.
another tomcat listening 8080 on the same machine, did do well, but
it's the application servlet took forever to start.
the cpu and memroy of the machine are all free, so no worries there..
any ideas on what to search for?
- 2
- Optional EJB2.x CMP many-to-one relationhipsIf I'm creating a CMP many-to-one relationship for an entity bean and that
link is optional, if the link is not active must I set a null value into
the field representing the many end of the relationhip?
For example, I have an Address entity bean that includes an integer
'RegionID' field. This field value is optional. I want to create a
relationship field that allows the Region entity to be accessed from the
Address entity. As the address to region many-to-one link is optional must
I set the default value of RegionID to be null?
- 2
- EnumSet + contains: strange behaviorDear all,
The following example of EnumTest seems to be inconsitent with the
interface definition of contains: It executes the lines marked with
XXX, which clearly is an error. Does anyone have an explanation?
Thank you,
Ulrich
import java.util.*;
public class EnumSetTest
{
public enum EnumTest
{
ONE,
TWO,
}
public final void testEnumSet()
{
final EnumSet<EnumTest> result = EnumSet.noneOf(EnumTest.class);
if(result.isEmpty())
{
System.out.println("empty"); // enters this branch: correct
}
else
{
System.out.println("not empty");
}
if(result.contains(EnumTest.ONE));
{
System.out.println("error"); // XXX
}
if(result.contains(EnumTest.TWO));
{
System.out.println("error"); // XXX
}
}
}
- 3
- Ug. what is wrong with this classloader???Hi, I keep getting the following error:
java.lang.NoClassDefFoundError: com/mydomain/tst/TestClass (wrong name:
com/mydomain/tst/TestClass)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.lang.ClassLoader.defineClass(ClassLoader.java:431)
at com.mydomain.loader.TNTClassLoader.findClass(TNTClassLoader.java:194)
at com.mydomain.loader.TNTClassLoader.loadClass(TNTClassLoader.java:115)
at com.mydomain.loader.TNTClassLoader.loadClass(TNTClassLoader.java:104)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at com.mydomain.prm.bo.Test.redirectCheck(Unknown Source)
... 40 more
What causes this? Here is my code: (Search for the 'Chokes here') Note: I
am running under java 1.4
======================================================
package com.mydomain.loader;
import com.mydomain.rmi.*;
import com.mydomain.util.*;
import com.mydomain.exceptions.*;
import java.util.*;
import java.io.*;
import java.net.*;
/**
* Used to load TNT classes. TNT classes start with com.mydomain. There will
be
* one class loader for each environment file.
*
* @author Troy
* @version $Revision$
*/
public class TNTClassLoader extends ClassLoader {
private Context _context;
private ClassLoader _common;
private String _product;
private String _version;
private String _classKey;
private TNTClassLoader(Context context, ClassLoader common) {
super(common);
_context = context;
_common = common;
InsensitiveProperties p = _context.getEnvironment();
_product = p.getProperty("product");
_version = p.getProperty("version");
_classKey = _product + _version;
_classKey = _classKey.toLowerCase().trim();
} // constructor
protected synchronized Class loadClass(String name, boolean resolve)
throws java.lang.ClassNotFoundException {
boolean useTNTLoader = true;
String product = null;
if (name.startsWith("com.mydomain.")) {
int lastDot = name.lastIndexOf(".");
// should always be greater than 12 unless the package name is
'com.mydomain'
if (lastDot > 12) {
// match the product name to the product field in the
environment field
product = name.substring(13, lastDot);
} // end if
// ignore core packages
if (product == null ||
StrU.inStr(1,"/util/data/rmi/loader/","/"+product+"/") != 0) {
useTNTLoader = false;
} // end if
} else {
useTNTLoader = false;
} // end if
// use the regular classloader
if (!useTNTLoader) {
System.out.println("using parent classloader");
Class c = _common.loadClass(name);
if (resolve) {
resolveClass(c);
} // end if
return c;
} // end if
// match the product name to the product field in the environment
field
if (_product == null) {
throw new ClassNotFoundException("environment: " +
_context.getEnvironmentName() +
" does not define the product
field.");
} // end if
// make sure we are using the correct classloader
if (!product.equalsIgnoreCase(_product)) {
// the product doesn't match. we need a different classloader
// find the name of the actuall environment
InsensitiveProperties p = _context.getEnvironment();
String actualEnvironment = p.getProperty(product +
"Environment");
if (actualEnvironment == null) {
throw new java.lang.ClassNotFoundException(
"Actual environment could not be found, environment: " +
_context.getEnvironmentName() + ", product: " +
product);
} // end if
InsensitiveProperties pp =
_context.getEnvironment(actualEnvironment);
String checkProduct = pp.getProperty("product");
if (checkProduct == null) {
throw new ClassNotFoundException("environment: " +
actualEnvironment +
" does not define the
product field.");
} // end if
if (!checkProduct.equalsIgnoreCase(product)) {
throw new ClassNotFoundException("unable to find product -
environment: " +
_context.getEnvironmentName() +
", product: " + product);
} // end if
Context context;
context = (Context)_context.clone();
context.setEnvironmentName(actualEnvironment);
TNTClassLoader loader = getClassLoader(context, _common);
return loader.loadClass(name, resolve);
} // end if
/** @todo get class here */
System.out.println("using TNT classloader");
// First, check if the class has already been loaded
Class c = findLoadedClass0(name);
if (c == null) {
// If still not found, then call findClass in order
// to find the class.
c = findClass(name);
} // end if
if (resolve) {
resolveClass(c);
} // end if
return c;
} // loadClass
private Class findLoadedClass0(String name) {
// StaticClassCache is a synchronized cache
return StaticClassCache.getClass(_classKey,name);
} // findLoadedClass0
public static synchronized TNTClassLoader getClassLoader(Context
context, ClassLoader parent) {
String key = "System.classloader."+context.getEnvironmentName();
TNTClassLoader loader = (TNTClassLoader)StaticLoaderCache.get(key);
if (loader == null) {
loader = new TNTClassLoader(context,parent);
StaticLoaderCache.put(key,loader);
} // end if
return loader;
} // getClassLoader
protected Class findClass(String name) throws
java.lang.ClassNotFoundException {
String fileName = name.replace('.','/');
File file = new
File(_context.getLocation(),_product+_version+"/busobjs/"+fileName+".class")
;
System.out.println(file);
if (!file.exists()) {
throw new ClassNotFoundException(name);
} // end if
// Looking up the package
String packageName = null;
int pos = name.lastIndexOf('.');
if (pos != -1)
packageName = name.substring(0, pos);
Package pkg = null;
if (packageName != null) {
System.out.println("the package name is: "+packageName);
pkg = getPackage(packageName);
if (pkg == null) {
System.out.println("the package does not exist");
} else {
System.out.println("the package exists");
System.out.println(pkg.getImplementationTitle());
System.out.println(pkg.getImplementationVendor());
System.out.println(pkg.getImplementationVersion());
System.out.println(pkg.getName());
}
// Define the package (if null)
if (pkg == null) {
definePackage(packageName, "spectitle", "specversion",
"specvendor",
"impltitle", "implversion",
"implVendor", null);
} // end if
} // end if
byte[] buffer = new byte[8000];
try {
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
int result = 0;
while ((result = fis.read(buffer)) != -1) {
bos.write(buffer,0,result);
} //wend
fis.close();
bos.flush();
byte[] bytes = baos.toByteArray();
bos.close();
System.out.println("number of bytes in class is "+bytes.length);
System.out.println("trying to define class: "+name+"|");
Class c = defineClass(name, bytes, 0, bytes.length); //
<----Chokes here!!!!
System.out.println("class is defined!");
return c;
} catch (IOException ex) {
throw new ClassNotFoundException(ex.toString());
} // try
} // findClass
} // class
- 5
- looking for java/JSP code to create my own RSS feed (with my own content)I am urgently looking to create an RSS feed supplying my own content
(which would be generated by unix/sql commands on my lab systems/
services and their state e.g "LDAP server not responsive"), does
anyone know where I can get code to do this? Or modify an existing
implementation?
thanks in advance
- 5
- a quizz question about java bit operation???hi ,
what is the value of
-8>>-1
-8<<-1
it will be like
public class BitOperation {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(-8 << -1);
System.out.println(-8 >> -1);
}
}
the result is
0
-1
but if not -8, what will be the value?and why???
- 5
- JTree and associating objects with nodesHi,
Sorry, ignore that last post. wrong component. Does anyone know how to store
objects in a name value pair data structure (i.e. hashmap) in a JTree? It
easy to store the name of the object but to store the object with the name,
I am not sure.
Any help would be great
Thanks
Bob
- 5
- Singletons and Serialization QuestionI am operating within Tomcat 6. I use 'collector' singletons to build
complex trees of objects from database queries. These singletons rely
on a pool of connections to various data sources, which are made
available via a 'connection pooling' singleton like this:
Connection
con=DriverManager.getConnection(MyPoolingSingleton.getPool("dbwrite"));
where "dbwrite" is the name of a connection that was established
earlier having certain permissions, etc.
My goal is to remove the 'collector' singletons to an app server and
obtain copies of them on a web server via serialization. They still
need access to the database after they are created. In this case the
'connection pooling' singleton must be instantiated locally on each
web server, since connections cannot be pooled across multiple JVM's
in my little world.
My question is, how to ensure the MySingleton.getPool() method call
points to the local singleton and not the singleton from the
originating server. Is it sufficient to ensure MyPoolingSingleton is
not serializable? Do I need to use a mechanism like a transient
instance variable to get a reference to the local copy of
MyPoolingSingleton?
Thanx all!
- 5
- Microsoft Hatred FAQIn comp.os.linux.misc John Wingate <email***@***.com> wrote:
> Peter T. Breuer <email***@***.com> wrote:
>> In comp.os.linux.misc Jeroen Wenting <jwenting at hornet dot demon dot nl> wrote:
>>> Without Microsoft 90% of us would never have seen a computer more powerful
>>> than a ZX-81 and 90% of the rest of us would never have used only dumb
>>> mainframe terminals.
>>
>> Uh - when microsoft produced dos 1.0, or whatever it was, I was sitting
>> at my Sun 360 workstation (with 4M of RAM, later upgraded to 8M),
>> running SunOS 3.8 or thereabouts.
> Peter, if you are serious, and not just pulling our legs, your memory is
> failing.
Well, it might be a bit off. I am talking about 1986.
> MS-DOS 1.0 came out in August 1981; SunOS 3.0 in February 1986.
Seems about right.
So what version of msdos was around at that time? Obviously I didn't
use it!
> Sun Microsystems was incorporated (with four employees) in February 1982.
> There never was a SunOS 3.8. (SunOS 3.5 was succeeded by 4.0.) And I'm
It seems to me that I was using 3.x. Maybe it was 3.1? I seem to
remember an earlier major ... was there a 2.8 or 2.9?
> not sure what you mean by "Sun 360"--a Sun 3/60, maybe?
Seems likely. I recall it as a Sun 360m. "Monica" by name, following
the cpu serial number, mncaxxx (or something close). "Sun 3" definitely
rings a bell.
Peter
- 8
- linux-sun-jdk15 or jdk15 on 5.3R-p2Hello,
I am another user who is not able to get linux-sun-jdk15=20
working on a 5.3-R machine. Truss shows:
linux_mkdir(0x805cba8,0x1ed) ERR#17 'File exists'
linux_lstat64(0x805cba8,0xbfbfc740,0xbfbfc898) =3D 0 (0x0)
linux_open("/tmp/hsperfdata_root/77570",0x242,0600) =3D 3 (0x3)
oftruncate(0x3,0x8000) =3D 0 (0x0)
linux_mmap(0xbfbfc8d0) =3D 681074688 =
(0x28986000)
close(3) =3D 0 (0x0)
#224() ERR#78 'Function not =
implemented'
SIGNAL 12 (SIGSYS)
SIGNAL 12 (SIGSYS)
Process stopped because of: 16
process exit, rval =3D 140
Bad system call
Is there a timetable on native support for 1.5 or=20
fixture of the linux-sun-jdk15 port? Should someone=20
mark the port as broken or remove it? It sounds like=20
it does not work on 4.x or 5.x at all.=20
-Will
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 11
- Online Chat, March 15, on HotSpot VM PerformanceJ2SE 5.0 includes a number of new features that can be used to enhance
the performance of the HotSpot Virtual Machine. Learn more and get
questions answered about HotSpot VM performance in this chat with Sun
engineers, Peter Kessler and Ross Knippel. Peter is the technical lead
for garbage collection in the HotSpot VM. See Peter's blog. Ross
focuses on the HotSpot Server Compiler. The chat is scheduled for March
15 at 11:00 A.M. PST (2:00 P.M. EST/19:00 UTC).
To join the chat, go to
http://java.sun.com/developer/community/chat/index.html on March 15 and
click on the "Join" link for the session.
- 11
- Create new object the MenuItem is pressedHello,
I have develop an application, but I am having som problems what
eventshandling when a MenuItem in a Frame is pressed.
/*
menuFileUpdate.addActionListener(new Update());
*/
In this code the Update-object is created when the main-program i
initalized. This i a problem - I would like that the objekt is created at
"pressing time". Do anyone god any suggestion to how this i done?
The update-objekt i an class implementes Runnable. This class is af
singleton with a static instance. What I do right how is to test if the
static object i null, and if is I create a new one, and start the thread.
How ugly is it to set the static instance= null when the job is done - and
thereby create thread-objects if the getInstance() is called?
Do it give any proformace to run the Frame in a thread calling invalidate,
and let the Update run in a the too?
Thanks,
Brian
- 13
- Problems Skewing Image (Trapezoid) with Graphics2Dhello!
right now i am working on a graphical output for a video projector. the
projection will be thrown on the wall from a little off center, so that i
will get the picture as a vertical trapezoid (the projectors i am using are
only able to correct horizontal trapezoids). my java program will have to
correct the effect. therefore i need to transform my graphics2d buffered
image NOT shearing the image, but genuinly skewing the image (that is two
parallel sides and two non parallel ones), as it would probably be possible
in java3d with the tilting of a plane.
how is it possible to skew rectangles with graphics2d?
thanks in advance!
roland
- 14
- Certificate was issued by an unrecognized entityI have problems running my application on the Samsung phones (SGH-E720,
SHG-E300) for HTTPS connection to server, I got next error on mobile
phone:
"Certificate was issued by an unrecognized entity Certificate:C=US;
O=VeriSign, Inc;OU=Class 3 Public Primary Certification Authority"
I checked certificates on both side: server certificate is present on
mobile phone, but still I got errors.
OU = Class 3 Public Primary Certification Authority
O = VeriSign, Inc.
C = US
Serial: 70 ba e4 1d 10 d9 29 34 b6 38 ca 7b 03 cc ba bf
Valid from Monday, 29. January 1996
Valid to Wednesday, 2. August 2028
Also, I have problems to install new certificates on mobile phone (I
tried via Bluetooth, WAP push, but mobile phone doesn't recognize that
it's a certificate and he can't handle this file.
BTW, same application is working properly on other vendor's phones
(Siemens, Motorola, Nokia,..)
Did somebody have similar problems and find some solution ?
Thanks in advance
- 15
- remote JBoss on local consoleI'm using Eclipse 3.0 IDE and JBoss 3.2.3 app server for building and
deploying EJB's. The Problem is that JBoss is on another PC and when I
deploy my bean the eclipse console shows only that my jar file is
copied to the server directory.
no debug , no error messages ...
so my question is how to make server debugging shows up on my eclipse
console
|
| Author |
Message |
Michael G.

|
Posted: 2004-8-4 6:34:00 |
Top |
java-programmer, Speeding up jsp
Hello, I'd like to know about ways to speed up a java application.
We're using jsp java beans on a webserver running Apache/Tomcat 4.1.18.
It's accessing database information through ODBC from a Microsoft SQL Server
version 8.0 database across a network. We're encountering some problems
with one jsp page because I think it's retrieving a large result set from
the database. The query in question selects from a database with over 30000
records. We're using JDBC, and limiting our select to only one database
column.
Any recommendations about speeding up the specific problem with this jsp
page, or any general suggestions on performance improvements would be
welcome.
Mike
|
| |
|
| |
 |
robC

|
Posted: 2004-8-6 0:23:00 |
Top |
java-programmer >> Speeding up jsp
Put your query in query analyzer, find out if it is the DB, or the
network. If it's the DB, try creating indexs to speed it up, if it's
the network, reduce your result-set size, try pulling back just the top
x rows instead of the whole thing. If you need all the rows, and you
are being limited by network bandwith, you are SOL :-)
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Question for Java GurusOn Tue, 18 May 2004, email***@***.com wrote:
> I suspect that the difference lies in how fundamental we think
> those concepts are. I think that the classpath environment
> variable is a rather peculiar aspect of the JDK command-line
> tools. I much prefer, say, Eclipse 3.0, where I can choose
> project properties and just check all of the user-defined
> libraries that my project uses and expect everything to work,
> without dealing with questions of whether I can set an
> environment variable in one place or another, or oops I only
> set it in this shell so it doesn't appear in other shells, etc.
> I think it's clearly possible to develop Java software without
> worrying one bit about environment variables. So I question
> why understanding the CLASSPATH environment variable (or
> command-line option, etc) would be a necessary prerequisite to
> learning programming in Java.
This is analogous to java programmers thinking they can code
database applications without understanding the underlying
database. Oh, I'm sorry, the JVM is the only world one needs to
know.
--
Galen Boyer
- 2
- How to process 1000 request using ThreadI have one problem. What is the optimal approach for handling 1000
request by using thread.there are 2 scenario. 1 create 1000 thread and
execute the program 2. create 10 thread and pool 1000 requests by some
scheduling algorithm.
- 3
- Error Code / Number ?Hi Group
is there any way to get the Error Code or Number related to the error ?
(Say within catch bolck)
Is java support that type of thing ?
What can i get from hashCode ?
Dishan
- 4
- Open Source OCR for Java/C++I found a lot of open source ocr projects from the net. But none of
them was usable.
Could anyone recommend an open source OCR programs to me?
For Java or Windows VC++ or Linux G++
Thanks
Jack
- 5
- Is the design of 'ArrayList' good ?
Occasionally I think that the design of 'ArrayList' is not good.
Because ...
The access modifier of 'E[] elementData' in 'ArrayList'
is 'private'. That is, Java do not allow a programmer
to access 'E[] elementData'.
Therefore, he will write the following statements to
sort 'ArrayList'.
<example>
List<String> strList = new ArrayList<String>();
Collections.sort(strList); // <- #1
</example>
By the way, the source of #1 is as follows.
<Quote>
public static <T extends Comparable<? super T>> void sort(List<T> list) {
Object[] a = list.toArray(); // <- #2
Arrays.sort(a); // <- #3
ListIterator<T> i = list.listIterator();
for (int j=0; j<a.length; j++) { // <- #4
i.next();
i.set((T)a[j]);
}
}
</Quote>
If 'strList' is large array, #3 is merge sort.
Merge sort requires 2 * M when M is the memory
size of 'strList'.
Because the memory size of 'a' in #2 is M,
'Collections.sort' requires 3 * M and has to execute #4.
It seems inefficient. (note that 'strList' is large array)
If the access modifier of 'E[] elementData' is 'protected',
he can sort 'strList' with 2 * M and without #4.
What is your comment ?
Thanks.
- 6
- xerces parseri have slight problem:
i downloaded the xerces xml-parser and want to use the DOMParser class:
import org.apache.xerces.parsers.DOMParser;
later in code:
DOMParser parser = new DOMParser();
this class resides in a jar-file which i put in my classpath
(/dir/xalan-j_2_6_0/xercesImpl.jar)
jar -tvf reveals the DOMParser class is there, but the compiler says it
can't resolve the symbol.
Is this because you can't access this class directly anymore?
Should i use JAXP, to access it?
anybody an idea?
tx
- 7
- [OT] Java 7 features: PLEASE STOP IT! All of you.This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Twisted schreef:
> On Aug 2, 8:29 am, Lasse Reichstein Nielsen <email***@***.com> wrote:
> [overly verbose off-topic commentary]
Subject says it all.
H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
- 8
- Java Hotspot VM Client 1.4.2.xxxx ???hi,
i've installed JDK 1.4.2, then I installed netbeans 5.0, and have
netbeans use this JDK version (I've uninstalled previous JDK versions
installed on my machine prior to installing 1.4.2). now, netbeans says:
"broken platform 'Java_Hotspot_TM__Client_VM_1.4.2_08-b03'...
From Sun's site, Java Hotspot is included in JDK 1.4.2, but where can
I find the jar file for it (i don't even know the name of the jar
file)?
your help is appreciated.
crash.test.dummy
- 9
- got packages working/////////command line///////////////
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>javac @comp
C:\>java -classpath
.;C:\java\classes\org\w3c\tidy\Tidy.jar;C:\java\classes\
atreides.jtidy.Tid
yTest
C:\>type comp
-d C:\java\classes\
-g
-sourcepath C:\java\sources\
-classpath .;C:\java\classes\;C:\java\classes\org\w3c\tidy\Tidy.jar
C:\java\sources\atreides\jtidy\TidyTest.java
C:\>type C:\java\sources\atreides\jtidy\TidyTest.java
// adapted from source available at:
//
<http://sourceforge.net/docman/display_doc.php?docid=1298&group_id=13153>
package atreides.jtidy;
import java.io.IOException;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.FileWriter;
import org.w3c.tidy.Tidy;
public class TidyTest implements Runnable {
private String url;
private String outFileName;
private String errOutFileName;
private boolean xmlOut;
public TidyTest(String url, String outFileName, String
errOutFileName,
boolean xmlOut) {
this.url = url;
this.outFileName = outFileName;
this.errOutFileName = errOutFileName;
this.xmlOut = xmlOut;
}//tidyTest
public void run() {
URL u;
BufferedInputStream in;
FileOutputStream out;
Tidy tidy = new Tidy();
tidy.setXmlOut(xmlOut);
try {
tidy.setErrout(new PrintWriter(new
FileWriter(errOutFileName),
true));
u = new URL(url);
in = new BufferedInputStream(u.openStream());
out = new FileOutputStream(outFileName);
tidy.parse(in, out);
}//try
catch ( IOException e ) {
System.out.println( this.toString() + e.toString() );
}//catch
}//run
public static void main( String[] args ) {
String url = "http://www.google.com/";
String output = "output.txt"; //specify path?
String errorLog = "errorLog.txt"; //specify path?
TidyTest t1 = new TidyTest(url,output,errorLog,true);
Thread th1 = new Thread(t1);
th1.start();
}//main
}//TidyTest
C:\>
- 10
- 11
- animation in custom table cell rendererDoes anybody know how to make animated gifs work in cell renderer?
I'm trying to use JLabel as base component with animated gif as image.
It works perfectly anywere except JTable...
- 12
- change money program - newbie questionHi,
I would appreciate any help I can get with this. The program accepts a
range of numbers (dollors) and provides a combination of the least
amount of bills and coins needed to make change for the input. This
program works for most numbers but there is a bug. try 19.99 and you
will see that the change is a penny short. Thanks for your help.
-R
public class MoneyDriver {
public static void main(String[] args) {
if(args.length != 1){
System.out.println("Please suppy only one argument on the command
line");
return;
}
double dblAmount = Double.parseDouble(args[0]);
Money m = new Money();
m.changeMoney(dblAmount);
}
}
public class Money {
Money (){
}
public void changeMoney(double dblAmount){
if((dblAmount < 0.01) || dblAmount > 9999.99){
System.out.println("The number you entered is out of range. Please
enter a number between 0.01 and 9999.99");
return;
}
double [] dblMoneyDenomination = {100.00, 50.00, 20.00, 10.00, 5.00,
1.00, 0.25, 0.10, 0.05, 0.01};
int count = 0;
for(int i = 0; i < dblMoneyDenomination.length; i++){
while((dblAmount > dblMoneyDenomination[i])){
++count;
dblAmount = dblAmount - dblMoneyDenomination[i];
}
if(count != 0){
System.out.println("Change is " + count + " " +
dblMoneyDenomination[i] + " bill(s)");
}
/* if(i + 1 == dblMoneyDenomination.length){
System.out.println("Change is " + ++count + " " +
dblMoneyDenomination[i] + " bill(s)");
}
*/
count = 0;
}
}
}
- 13
- Creating a (META) FAQ for c.l.j.g? (was: Re: New to the group)"S. Balk" <email***@***.com> writes:
> There is no FAQ for this newsgroup, maybe not that bad to have one...
You think so? There is so much good stuff out there that I don't think
a full FAQ is needed. What is maybe needed is some kind of meta FAQ
pointing to the most interesting stuff (the stuff which we always refer
newbies to).
What is the group's opinion about this? I would volunteer to create
such a meta FAQ if there is sufficient demand. It would be based on the
list of resources I post from time to time in response to newbie
questions.
/Thomas
- 14
- change jscrollpane bar?hi,
is it possible to change the scrollbar in a jscrollpane? i wanted to
replace it with an image, is this possible? i just want to change it's
look, i've see some skins but not exactly what i wanted, and i'm not
sure how to make my own skin. if it's possible can someone tell me
how, or point me to a place that shows how to create look and feel
skins for java applications?
Thank you.
- 15
|
|
|