Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 19548

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.

1 vote
Accepted

Graph degree as solution for undirected graph paint

It is not. Consider a triangle graph which has tree nodes and three edges. All vertices has degree two but three colors are required to color it. Your function would fail for that input. In fact, th …
Gaslight Deceive Subvert's user avatar
4 votes
Accepted

Merge Sort in Java with Test cases

That is, the same names used by the Arrays class in the Java standard library: data => a comparator => c start => fromIndex stop => toIndex I've never seen the center element in merge sort being referred … Inclusive start, exclusive end It is better to use inclusive start indices and exclusive stop indices, matching the convention established by Arrays.sort and many other array functions in the Java standard …
Gaslight Deceive Subvert's user avatar
2 votes

Pong-Like Game. First game I ever made. advice needed

x = PaintSurface.getPaintSurfaceDimension().width - width; you write: x = Math.max(0, Math.min(x, PaintSurface.getPaintSurfaceDimension().width - width)); The idiom is so common that many Java
Gaslight Deceive Subvert's user avatar
1 vote

Find min sum for indices to match equation

There is lots of symmetry and short-circuiting you can exploit here. Every loop-iteration is independent and duplicates are pointless to test. E.g a = 1 and b = 2 gives the same result as a = 1 and b …
Gaslight Deceive Subvert's user avatar
2 votes
Accepted

Java RSA / AES-GCM encryption utility

Mixing Java NIO with old style IO is not nice. … Your code for writing the keypair to file can be replaced with Java NIO calls: byte[] encodedPrivateKey = keyPair.getPrivate().getEncoded(); byte[] privateKeyBytes = encrypt(encodedPrivateKey, password …
Gaslight Deceive Subvert's user avatar
3 votes
Accepted

Java file analyzer byte-by-byte

Replace try (FileInputStream fis = new FileInputStream(file)) { with try (InputStream fis = new BufferedInputStream(new FileInputStream(file))) { See also Why is using BufferedInputStream to rea …
Gaslight Deceive Subvert's user avatar