Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [java]

Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

31
votes
2answers
32k views

Custom CursorAdapter Design

Here's the code which I use for my Android custom cursor adapter which I use to bind data to my list view. ...
2
votes
1answer
2k views

Hibernate proxy converter for GWT

Here's a class that converts Hibernate proxies to normal classes. This is useful with GWT for example, when sending objects loaded from database to the GWT client. Please review it. ...
4
votes
1answer
463 views

Dao function using hibernate

I'm just wondering if the following is the best way to write a dao function. Should I get the entity manager before the transaction and close it after the transaction every time? Should I write ...
7
votes
2answers
2k views

How to increase download speed using the following method?

I have written an Android application which downloads pdf files through web service. I am using kSoap2 android library to parse the response of web service which basically contains file name & ...
6
votes
1answer
1k views

Optimized thumbnail generation

Here is a snippet of code that generates a thumbnail from a given file. It works well, but is much slower than desired. Without using an external library (which I'm trying to avoid for learning ...
6
votes
3answers
14k views

Data validation for preventing blank entries

I want to create a validation wherein blank entries will not be accepted. So if I call this code: ...
4
votes
3answers
2k views

“Consecutive Heads” program

So... I have a program in which I want to flip heads three times in the row. What I'm asking for is for proposals of other solutions for this program, in pro way, as You do in natural sense. That's ...
15
votes
2answers
2k views

Guessing game - am I using the concept of objects in Java properly?

I'm new to Java and find it hard to grasp the concept of objects. I wrote a simple guessing game to practice the concept of OO programming but I am not sure if I am doing it correctly. The objective ...
8
votes
1answer
1k views

Implementing a fast 'split' function on a stream of characters in Java

I was writing a piece of code (a custom EntityProcessor for Solr, but that isn't too relevant) designed to break lines of input based on a string delimiter (...
6
votes
1answer
2k views

Parser for CNF formulas

I have a parser for CNF formulas in Dimacs format, which is very slow. Any suggestion on how to improve its speed? I did some profiling and I might have to replace ...
9
votes
5answers
3k views

Providing unchecked exception “wrapper” interfaces for an API with checked exceptions

I recently had a discussion in the forum of an API, because they changed an exception from checked to unchecked. I believed it needs to be checked, because it is recoverable. The arguments of "the ...
7
votes
1answer
560 views
8
votes
3answers
3k views

Java synchronous queue implementation

I just want to make sure there aren't any deadlocks or inconsistencies (the code is also available on github). Disclaimer - In real life, I would not implement a queue myself, but use an existing ...
11
votes
2answers
809 views

Setting up radio button click listeners

Do you have any suggestions for improving it? Instead of writing four almost identical setOnClickListener method calls, I opted to iterate over an array, but I'm ...
7
votes
2answers
1k views

Multithreaded log test

I'm writng a logger extension that allows multiple threads to log a process and then dump that log to the main log in one atomic operation. The point of it is to make the logs easier to read when many ...
7
votes
4answers
511 views

Spawning threads to process data

I have a class that spawns threads to process data. I am working on instrumentation code. When the process is started, time = System.currentTimeMillis(); When it ...
1
vote
2answers
213 views

Function to turn to requested bearing

I've been writing a function: float turnToRequestedHeading(float initialHeading, float requiredHeading, float turnRate) I keep thinking there must be a clever ...
11
votes
3answers
18k views

Simplified Android Spinner

I have written a simple spinner wrapper, but was wondering if any of you could think of any ways to make it more robust. It only handles strings at the moment. ...
7
votes
6answers
451 views

Arguments in constructors matching fields

What is your opinion in arguments in constructors matching members as in the following example ...
11
votes
3answers
2k views

Pattern Against Anemic Domain Model

I would like to solicit advice on everyone's thoughts on how best to combat the Anemic Domain Model anti-pattern when building out a system based on web services. One of our goals is to build a set ...
6
votes
1answer
808 views

Android ListAdapter design advice

I want to write an Android ListAdapter to serve data from a database that look like this: ...
1
vote
2answers
631 views

Hibernate transaction advice [closed]

I'm new to Hibernate so I need some advice/direction on doing Transactions. I have a DAO like ...
14
votes
4answers
398 views

Finding subtuple in larger collection?

I've got a flat array of < 1000 items and I need to find the indices of a smaller tuple/array within the array. The tuple to find can be a varying length (generally between 2 and 5 items, order is ...
43
votes
5answers
13k views

Thread-Safe and Lock-Free - Queue Implementation

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...
22
votes
4answers
2k views

Law of Demeter and data models?

Inspired by this question, but hopefully not a duplicate. I understand that the Law of Demeter is very useful in case of services interacting with other services, for example it's much easier to mock ...
12
votes
2answers
666 views

HTTP request path parser

I have written a method to tokenize HTTP request paths such as /employee/23/edit: ...
16
votes
2answers
3k views

Shamos-Hoey algorithm for checking the self-intersection of a closed shape

I implemented the Shamos-Hoey algorithm to check if a closed shape is self-intersected. Is this algorithm ok in terms of performance? ...