java

How to limit the number of entries in a java List?

I know how to limit size in Map (like this,using LinkedHashMap.removeEldestEntry method does exactly that) I want to know how to limit size in a List,what is a best way to implement? thanks for help :) ...

Is there a way to only search for specific kinds of books such as textbooks with Google Book Search API?

I noticed that there are a few a classes such as CategoryFilter that can be used on the VolumeQuery in the Google Book Search Java API. Could this be used for only searching for specific kinds of books like textbooks, or is there a better approach to this kind of search? There doesn't seem to be too many examples online or details in the...

Book for type systems

Is there any book which explains type systems in programming languages? If it has mathematical account of type systems,that is much preferred. ...

File Comparison via Byte Array issues.

I am coding a class that compares the files of two directories via comparing the Byte arrays of each file. I am however not getting the expected results; identical files are not being resolved as identical files. First problem: Matching the files Byte[] with equals() resolves to false with matching files (Checked with only one file as ...

menu XML with MenuInflater

I made an XML file under my newly created res/menu folder. Menu.xml contains my menu definition for use with MenuInflater. The entire XML file looks like this: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; <item android:id="@+id/settings" android:title="@string/set...

Image mapping like feature in Java swing, Points vs GeneralPath

My gaol is to draw several images using 2D graphics in a paintComponent() method. However, I'm not sure how I could add a MouseListener such that each image would know if it was selected. My solution thus far is too simply record the coordinates of the mouse click, and see if they are contained within the boundaries of each of the image...

My Random Number Generator isn't doing what I intended it to be

This is a school project: Objective: Ask the user to input 2 number A random number will be print to the user. Must catch if input isn't Integer. I have check online source, which i copied the code and use it. Min + (int)(Math.random() * ((Max - Min) + 1)) The code work fine except if I input any integer less than 10. The Program...

What do you think about Tapestry 5.2?

I want to create a new project and I'm studing diferent web frameworks In StackOverFlow there are diferent threads of tapestry but it talks about Tapestry 4 or old Tapestry 5.0.8 What about tapestry 5.2, what do you think about it ? Thanks in advance ...

How to maximize image size as the size of the JPanel

How I can maximize the size of picture with the size of JPanel? ...

When method marked with @PostConstruct called?

At which phase of the JSF request processing lifecycle, the backing bean method marked with @PostConstruct called? ...

If I compiled a java file in the newest JDK, would an older JVM be able to run the .class files?

Does the bytecode depend on the version of the java it was created with? I hope the question is clear. Thanks. ...

How to solve javax.crypto.IllegalBlockSizeException: data not block size aligned

I am doing an assignment about use blowfish to do encryption & decryption in java. I had added a provider, and get instance "Blowfish/ECB/NoPadding", but I still get this error when I do the encryption. Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); e.g.: public static byte[] encrypt(byte to_encrypt[]...

how to convert words to number ?

Can anyone please help me on how to convert words into numbers in java programming, using string tokenizer. Your answer will be highly appreciated. for example four hundred four should be 404 ... thanks alot ...

tomcat is not taking my jar file in my webapps/myapp/WEB-INF/lib folder.

How do I make my tomcat to load jar files from my webapplication's WEB-INF/lib folder ? ...

My Android app keeps giving me a Leak Found error

Hi guys, I am working on an Android app but I keep getting a Leak Found error. Here's the Call Stack: 11-01 11:26:47.087: ERROR/Database(7317): Leak found 11-01 11:26:47.087: ERROR/Database(7317): java.lang.IllegalStateException: /data/data/com.noshufou.android.su/databases/permissions.sqlite SQLiteDatabase created and never closed 11...

GWT simple web form submit - redirect to new page

I have a simple web form written in Google web toolkit. I want the user to follow a new URL when he clicks on the submit button. However I cannot find any examples of redirecting the user to a new URL from within GWT code. How may I achieve this? ...

Why are "A" or no output only possible outputs of this code, it could also be "AB"?

According to what I have read, the only possible outputs for this program are "A" or no printouts. But since the statement new MyString("A").concat("B"); is creating a new object with string "AB", couldn't this object also be garbage collected resulting in output "AB"? class MyString { private String str; MyString(String str)...

How to handle data from one model panel to another in JSF richfaces ?

scenario: i have a model anel opened in whci i have a commandlink which opens another model to search for data adn the data is poplated in a datatable with a link in one of the column. On click of the link i need to fetch the row data an populate the value inside the parent model panel . Problem: i am not able t...

designing picture puzzle.

I am planning to develop a jigsaw puzzle game. Now I already have images and image pieces, so we don't need algorithm to cut the image in pieces. On the UI side there would be two sections First section contains the broken images in random order. Second section contains the outline of the full image. User need to drag and drop the the...

Where can I find RefFSContext source (from fscontext.jar)

I've downloaded glassfish source code but it's not in there. People used to point at http://java.sun.com/products/jndi/index.html#download but it seems this link has disappeared. Any idea ? Thanks ...