Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Newsletters Archive: 10

JavaFAQ Home » Java Newsletters Go to all tips in Java Newsletters


Bookmark and Share

******************************************************************
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* > The Java FAQ Daily Tips, weekly publication < *
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* *
* Issue No: 10 8 November 2000 *
* http://www.javafaq.nu/java *
* *
* *
* Please recommend us to your friends and colleagues! *
******************************************************************

Table of Contents

> How do I convert a binary number to an int?
> I would like to know how to test the memory, so as to avoid the
OutOfMemoryError?
> What is a Just-In-Time (JIT) compiler?
> I need to put in a JtextField characters like cyrilic ...
> How do I communicate from Java applet to JavaScript in the same
frameset?
> Is there any way to accept password from a java application?
> Is there a collection object like the hashmap or hashtable that
stores values in an ordered path? Hashmaps do not guarantee the
order of the objects...
******************************************************************

Hello dear friends!

We have two good news for you in our anniversary issue No_10 Smile!

First: We almost ready with compilation of our free for our
subscribers "100 Java Tips" e-book!
It will contain 100 Java FAQ tips from our site in comfortable for
reading and printing out form. We are planning to continue this
work and publish free to you "200 Java Tips", "300 ..." and so on.
When it will be big enough we are planning sale it, but not to you!
You will still get it for free as a subscriber of our newsletter!

And our tips here!
******************************************************************

Tip 1

I cannot find the method to convert a binary number to an int. I
used Integer.toBinaryString to get a decimal to binary but I don't
know how to to convert it back.

A: Try using Integer.parseInt (String s, int radix) with radix = 2
that should do your job


******************************************************************

Tip 2

I would like to know whether it is possible to test the memory, so
as to avoid the OutOfMemoryError or whether it is possible to
increase the amount of memory in the JRM.

Answer: You can get the total and available memory used by the VM
by making two calls from the Runtime class:

Runtime runtime = Runtime.getRuntime();
long free = runtime.freeMemory(); //the available memory
long total = runtime.totalMemory(); // the total for the JVM

The amount returned be totalMemory() isn't that useful unless you
specify how much memory your program will have from the beginning
(if you don't, the JVM will just keep grabbing more until
you run out).
You can set the initial and maximum memory from the command line:

java -Xms64m -Xmx64m name.of.Application

This will start your appplication with 64 megs initial and maximum
memory.

******************************************************************

Tip 3

What is a Just-In-Time (JIT) compiler?

Answer: It is a JVM that compiles Java instructions
(called bytecode) into native machine instructions at run time and
then uses this compiled native code when the corresponding Java
code is needed. This eliminates the constant overhead of
interpretation which tradition first generation JVM's used.


Tip 4

I need to put in a JtextField characters like cyrilic ...

How can I do this?

Answer: You use the unicode string u???? corresponding to your
character.
A table of codes can be found at www.unicode.org/charts/


******************************************************************

Tip 5

I need to communicate some data (string) from a Java Applet to
another ASP page in the same frameset. I would like to avoid a
server roundtrip and do it all with JavaScript if possible.

Therefore I would like to call some javascript from a Java Applet.
It looks like it is not possible without a netscape package. Is
that true? Is there a simple implementation of the same
functionality (source code), which I could incorporate in my applet?

Answer: Those Netscape packages are part of the current VM of
both Microsoft IE 4+ and Netscape 4+. So, by adding the MAYSCRIPT
tag to your Applet declaration, in the Java code you can obtain a
handle to the document and call functions in it.

******************************************************************

Tip 6

Is there any way to accept password from a java application? As it
is a password, IT SHOULD NOT BE SHOWN (ECHOED) WHILE IT IS ENTERED.

A: If you are using swing, you can use JPasswordField, and set your
echo character

******************************************************************

Tip 7

Is there a collection object like the hashmap or hashtable that
stores values in an ordered path? Vector does this but i need the
key/value functionality. Hashmaps do not guarantee the order of
the objects.

Answer: Take a look at java.util.TreeMap.
Red-Black tree based implementation of the SortedMap interface.
This class guarantees that the map will be in ascending key order,
sorted according to the natural order for the key's class
(see Comparable), or by the comparator provided at creation time,
depending on which constructor is used.

Note that this implementation is not synchronized. If multiple
threads access a map concurrently, and at least one of the threads
modifies the map structurally, it must be synchronized externally.


The Java FAQ Daily Tips is a newsletter that is only sent to those
who have specifically subscribed to it.

John Andersson, Editor mailto:info@javafaq.nu

Copyright (c) 2000 John Andersson
******************************************************************
You can find our tips on site also!
Please recommend us to your friends and colleagues!


 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy