text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
Java : I was reading jls 8 and I got stuck on Example 8.1.2-1 , Mutually Recursive Type Variable Bounds I searched stackoverflow , and found a question what is a mutually recursive type ? but this was not in terms of Java.Example 8.1.2-1 . Mutually Recursive Type Variable BoundsQuestion : What does Recursive Type and M... | Example 8.1.2-1 Of Java Language Specification ( Mutually Recursive Type Variable Bounds ) |
Java : I used to use enums as indexes in C. ( each enum something like an alias for an int value ) Example : With enums as indexes , I can always be sure that I am updating the right cell . Furthermore , I need the simplicity of arrays as well.I would like to do the same in Java . But , I cant seem to find a simple rep... | Is there a replacement for Arrays with enums as indexes ? |
Java : I am using a simple random calculations for a small range with 4 elements.When I attach the debugger I see that for the first 2-3 times every time the result is 1.Is this the wrong method for a small range or I should implement another logic ( detecting previous random result ) ? NOTE : If this is just a coincid... | Why random of 0 to 4 is 1 most of times ? |
Java : While I move my gaming mouse inside a javax.swing.JFrame , all animated GIFs ( javax.swing.ImageIcon inside a javax.swing.JLabel ) stops animating until the mouse stops moving.This only happens with a gaming mouse with a driver on macOS ( tested it with a Rocket-Kone XTD and a Razer gaming mouse on two computers... | GIF stops animating while gaming mouse is moving |
Java : Let 's consider the following example : Some languages allow us to specify \U $ 1 in place of $ 1 which converts matched groups with uppercase letters . How can I achieve the same using Java ? I know we can use Pattern class and get the group and convert it to uppercase , but that 's not what I am looking for . ... | Regex replace the substitution string |
Java : Interfaces : Attempt to use intersection type : Attempt to compile with javac 1.8.0_60 : Why this intersection type is invalid for javac ? <code> interface PublicCloneable { Object clone ( ) ; } interface HasPosition { // does n't matter } @ SuppressWarnings ( `` unchecked '' ) < E extends PublicCloneable & HasP... | unable to use an intersection type when notional class requires access modification |
Java : [ EDIT ] The solution of @ antonio works . See the screeshots below for proof..I am trying to use JorgeCastilloPrz 's AndroidFillableLoaders Library and this is the first time i am using SVG ( or Path for that matter ) . So please bear with me if the question is too naive.Library Link : https : //github.com/Jorg... | JorgeCastilloPrz 's AndroidFillableLoaders Library - SVGPath issue |
Java : In the code belowThen I can call new B ( ) .v ( 1 , 2 , 3 ) ; //print Sub rather than Super which is ridiculous but does work well . If I change B to the call to new B ( ) .v ( 1 , 2 , 3 ) ; will be invalid . You have to call it as new B ( ) .v ( new int [ ] { 1 , 2 , 3 } ) ; , why ? <code> class A { public void... | method signature in inheritance |
Java : My Java source code : The output is : ee1e2e3e.Why ? <code> String result = `` B123 '' .replaceAll ( `` B* '' , '' e '' ) ; System.out.println ( result ) ; | What is the effect of `` * '' in regular expressions ? |
Java : I 've been banging my head around , trying to figure what 's wrong with the following mapping . I understand the following mapping is not ideal for ORM , but that 's how the database is and I can not change its structure . I 'm using JPA 2.1 and Hibernate 5.0.2.Final.Besides this structure , I also have a conver... | Wrong TypeDescriptor when using JoinColumns in a composite Key |
Java : This is a simple code My question is : How Java knows that the passed null is Bar and not Foo ? I know why the compiler chooses Bar and not Foo ( because there is a conversion from foo to bar and from bar to foo and not vice-versa ) .But how would the method know this null comes from Bar and not Foo ? does null ... | Is a null reference an instance of a class ? |
Java : In java.util.stream.Stream interface , the combiner is a BiConsumer < R , R > , whereas in the combiner is a BinaryOperator < A > which is nothing but a BiFunction < A , A , A > .While the later form clearly defines what will be reference of the combined object after combining , the former form doesn't.So how do... | Out of the java.util.stream.Stream interfaces 's two collect methods , is one of them poorly constructed ? |
Java : I have a lambda that currently returns 1st row where date matches passed in date , by using RecordNumber.Here is my current code : Now , I have to add functionality for if ProEffectiveDate is null to simply return first row from the list.When ProEffectiveDate is null , how do I ignore this filter ? <code> ProLis... | Use lambda filter if element is not null otherwise ignore filter |
Java : If I write the Java methodthen I can call this method viaas well asand both calls are treated exactly the same . However , the two callsandare not treated the same . The section on evaluating arguments in the JLS states `` The final formal parameter of m necessarily has type T [ ] for some T '' so why is n't the... | How can one explain this seemingly inconsistent Java varargs behavior ? |
Java : The Java API documentations states that the combiner parameter of the collect method must be : an associative , non-interfering , stateless function for combining two values , which must be compatible with the accumulator functionA combiner is a BiConsumer < R , R > that receives two parameters of type R and ret... | Where is defined the combination order of the combiner of collect ( supplier , accumulator , combiner ) ? |
Java : I understand that the argument of myMethod ( ) being an int literal , and the parameter b being of type byte , this code would generate a compile time error . ( which could be avoided by using an explicit byte cast for the argument : myMethod ( ( byte ) 12 ) ) After experiencing this , I expected that the above ... | Why is an explicit cast not needed here ? |
Java : We are designing a system for processing XML messages.The processing Java class needs to split out various attributes and values from a largish XML and pass these as parameters to individual handler classes for varied operations.We have thought of following options : A ) Pass the entire XML to each handler and l... | Java OO design for handling large XML |
Java : I have two classes A & B , where B is derived from A . Both the classes have a method with same signature . They are called in the following manner in Java & c # -- > In case of JAVA : This program generates the following output : -In case of C # : This program generates the following output : -Why does the outp... | Why this difference of handling method ambiguity in Java & c # ? |
Java : When I 'm using a JXTable to render and edit my data , some input into the CellEditors gets lost . If I click on the Resizing-Divider of the JXTable-ColumnHeader or change the width of the JFrame , the CellEditor gets terminated without commiting the value . The values are saved if I use the JTable . I want to u... | Why is JXTable losing input where JTable is not ? |
Java : I am having trouble comprehending why parallel stream and stream are giving a different result for the exact same statement.ResultParallel : 1 , 2 , 3Result : 1 2 3Can somebody explain why this is happening and how I get the non-parallel version to give the same result as the parallel version ? <code> List < Str... | Parallel Stream behaving differently to Stream |
Java : I 'm trying to re-order my items list ( Using android getListView , not custom ) by distance and I 'm having issues.I 'm getting the Spherical distance in meters ( double ) using Maps Utils inside the adapter ( SomeAdapter ) .double distance = SphericalUtil.computeDistanceBetween ( fromCoord , toCoord ) ; But af... | Android re-order adapter by distance |
Java : I searched about a day now , but didnt find any example for my problem in Javacode.I have a worldmap with a size of 2000*1400 Pixels with a 'Mollweide ' projection.How can I find out what is the longitude and laltitude of the point ( 500,300 ) in my map ? I would like to code this in Java.I tried to do this with... | Get Longitude Laltitude of a point in my Worldmap in Mollweide projection |
Java : On page 140 of Effective Java we are advised that a method signature with a wildcard is preferable to one with a type parameter that only appears once . For example , is preferable toHowever it is not possible to set an item of a List < ? > to be anything ( except null ) so Effective Java suggests writing a priv... | Raw types and performance |
Java : The following signature is valid and commonly used in Scala : However , since > : is the Scala equivalent of super in Java , my first idea to convert this signature ( replacing the function type with BiFunction and making use of Use-Site variance annotations aka Bounded Wildcards ) would beBut oh no ! The compil... | Java 'reduceLeft ' signature / Lower-bounded Type Arguments |
Java : I made a little test to manipulate a short and I came across a compilation problem.The following code compile : while this one does n't : I 've read that shorts are automatically promoted to int , but what 's the difference between those two codes ? <code> short s = 1 ; s += s ; short s = 1 ; s = s + s ; // Can ... | Difference between s = s + s and s += s with short |
Java : What is the reason that the first line does not compile and the second and third one does ? <code> interface A { void s ( ) ; } public static void main ( String [ ] args ) { A a = ( ) - > 5 ; // DOES NOT compile A b = ( ) - > new Integer ( 5 ) ; // does compile A c = ( ) - > Stream.of ( 1 , 2 , 3 ) ; // does com... | Lambda Expression that has return type as void can compile with wrapper but not compile with primitive |
Java : I receive some crash reports from android ( with java.lang.NullPointerException ) , but I do n't understand what mean __null __ in stacktrace below : And I do n't understand what access $ xxx functions is ? Furthermore , formatElapsedTime is not called from onEnterPressed neither directly nor indirectly ! That i... | Strange stack at android crash report |
Java : Hello dear Programmers , I have a String String input = `` 30.09.1993 '' ; Then i want to save all numbers in this string in an array ( Only numbers ! ) . The `` . '' are at index 2 and 5 so i want to skip these parts of my string in my loop with an if-statement.I fixed my problem and everything works fine but I... | Logic of Java Operators & & and || |
Java : I 've been reading up on ( and experimenting with ) several Java mocking APIs such as Mockito , EasyMock , JMock and PowerMock . I like each of them for different reasons , but have ultimately decided on Mockito . Please note though , that this is not a question about which framework to use - the question really... | Value of Behavior Verification |
Java : So , I use IntelliJ IDEA to program in Java , and I was experimenting with the keyword instanceof and my code looked eventually like this : IntelliJ gives me at the two instanceof Two line a hint `` [ ... ] is allways true '' , but for one instanceof Two IntelliJ does n't give me a `` [ ... ] is always false '' ... | IntelliJ show `` always true '' hint but not `` always false '' for instanceof |
Java : How can a stream be created lazily ? During migration of collection based code I have run into this pattern multiple times : The resulting concatenated stream is typically processed lazily , as we know . Therefore the expensive collection is not needed at all , if the stream processing stops in the first part of... | Create stream lazily |
Java : I am opening file pick Intent with , Bellow code I Want remove Contact option from list , please can anyone help.Thanks <code> Intent intent_upload = new Intent ( ) ; intent_upload.setType ( `` */* '' ) ; intent_upload.setAction ( Intent.ACTION_GET_CONTENT ) ; activity.startActivityForResult ( intent_upload , Co... | Remove Contact select option form file select options |
Java : Right now I 'm implementing a method that has one parameter of the type Class and this method returns a boolean if the given class object requires an instance of it 's enclosing class for it to be instantiated.This method currently works as follows : To explain why it is designed as such : It first checks if it ... | Java : How do i determine whether a local class defined in an initializer block requires an enclosing instance for instantiation ? |
Java : I just want to replace one element with different list of elements , I ca n't find a way how to do it . Where dynamicContentHtmls is list of Elements and element is the one which should be replaced.My experimental code : <code> int i=0 ; for ( Element element : dynamicContents ) { //element.remove ( ) ; element.... | How can I replace one element with list of elements using jsoup ? |
Java : We are using openJDK11.0.6 java.net.http HTTP ( HTTP1.1 ) client to fetch content from websites . After a long execution time , we noticed a performance decrease . CPU is 100 % used even when the app does nothing . We were able to determine that it comes from a lot of app leaked socket ( CLOSE-WAIT state ) . The... | Connections leaking with state CLOSE_WAIT with java.net.HttpClient |
Java : Preface : I understand generics and how they 're declared at the class level ( e.g . class MyClass < T > ) but I 've never seen it declared at the level of a static method , and without any explicit bindings ( e.g . class MySubclass < String > extends MyClass ) .I found this code snippet in an app I 'm working o... | What is a generic method and how is < T > bound in this case ? |
Java : I 've developed a Jersey API which returns either XML or JSON ( depending on the request header ) . When deployed on my Windows 2012 server ( Tomcat ) , it works no problem.When I deploy ( after compiling it on Ubuntu ) to an Ubuntu machine in AWS ( Glassfish ) , I get the following errors when I request JSON : ... | Returning Json From Jersey on Linux Throws Exception |
Java : Referring to the FeedReaderContract class on Android Developers page : Saving Data in SQL DatabasesThe code starts as : i.e . there is a default public constructor for the class.Is that code comment correct ? How does a public empty constructor prevent instantiation - should this maybe be private ? ... am I stil... | Empty constructor in FeedReaderContract demo |
Java : i am planning to perform a standard list command to get a vector or a list of the content of a directory.I know this is easy by usingThe problem is that I need a list/array/vector of URLs . So my thoughts were to convert the files to URL . With the org.apache.commons.io.FileUtils library this is possible with th... | Fastest possibility of listing a directory and getting the URLs of every file in Java |
Java : In Java8When I write such code : Java8 streams are divided into two sections ; intermediate vs terminal operations , where the -AFAIK - actual action ( under-the-hood iterations ) is done in the terminal ops , while each intermediate ops appends its own -let me name it- Apply inner classes.By this , there will b... | Does Scala has intermediate/terminal ops as Java8 has ? |
Java : Following https : //developer.atlassian.com/bamboodev/bamboo-tasks-api/executing-external-processes-using-processservice I would like to invoke some command using ProcessService bean . The injection as described in the link , does not work . I checked the source of several other plugins at Bitbucket , but each i... | Bamboo ProcessService bean does not exist ? |
Java : I knew one can prevent the code formatting in eclipse by surrounding the code withBut I do n't want to write it manually all the time . It would be perfect just mark the code , press a hotkey and the code gets prevented from formatting.Anybody knows how ? Thx ! <code> // @ formatter : off// my awesome formatted ... | Prevent Code-Formatting in Eclipse by HotKey |
Java : The easiest way to convert a Java Collection to a Scala equivalent is using JavaConversions , since Scala 2.8.. These implicit defs return wrappers for the contained Java Collection . Scala 2.9 introduced parallel collections , where operations on a collection can be executed in parallel and the result collected... | How to create a Scala parallel collection from a Java collection |
Java : Lets say I have two observable streamsHow can I join these on when they have an attribute that matches ? Something like the psudo code below : <code> Observable < Book > books ; Observable < Movie > movies ; Observable < BookMoviePair > pairs = books.join ( movies ) .where ( ( book , movie ) - > book.getId ( ) =... | RxJava join observable streams by matching attribute value |
Java : Can I instantiate a concrete Java class that uses recursive generics in Kotlin , if so then how ? DetailsI am trying to instantiate a Java class that uses recursive generics similar to the example below . I found a work around for wrapping the Java class in a new class , but that feels like I am sidestepping a p... | Instantiate a concrete Java class that uses recursive generics in Kotlin |
Java : I am trying to understand what the following means ? What is the advantage of doing something like this ( e.g . use-case ? ) . <code> public class Bar < T extends Bar < T > > extends Foo < T > { //Some code } | Java generics syntax |
Java : I have the following available methods in a Utils class : And in a method of myClass I have : The second piece of code has a compilation error : The method withTx ( Function < OrientGraph , Object > ) is ambiguous for the type myClassI guess this comes from the compiler , which is not able to determine if the la... | Disambiguate overloaded methods that accept different functional interfaces |
Java : Mouse events and scroll events behave in different waysMouse Events : The event is captured by mainStageThe event is captured by mainStageThe event is not capturedScroll Events : The event is captured by mainStageThe event is captured by secondStageThe event is not capturedIs there any way that transparent secon... | Transparent JavaFX stage capture scrolling events if there is another window behind |
Java : Can someone imagine when this code : should become this : ( In our company we have a Sonar rule that forces such coping or arguments for all methods . ) I can imagine why it can be important for standard methods , but I can not find any benefit of having it done at a start of tools main method . Am I missing som... | should MAIN method copy input arguments ? |
Java : I have a problem when trying to persist a data model class into a database . I have a class like this : The second field was added after first one . When to persist object created with this class via : A new row in database is created , but only with first field added . The second one is empty . When I am debugg... | Can not persist data model 's field into database , but can retrieve it |
Java : Abstract : I would like to interact with two classes ( 'Item ' and 'Block ' ) that share many similar functions as if they were implemented from an interface with these functions , however they are not and I can not edit them . What are my options for dealing with this ? Am I stuck writing super hacky code ? Det... | Forcing two similar classes to behave as if they were polymorphic in Java |
Java : Consider : I found no way to express that I mean the X from Bar < X > and not Foo.X in the foobar ( X t ) implementation . Is there no other way than renaming the generic parameter X in Bar or the static inner class ? <code> public interface Foo < T > { public static class X { } public void foobar ( T t ) ; } pu... | Generics name clash |
Java : I am developing a programming tool on the Netbeans Platform.In that , I have an action to find usages and I want to add Alt + F7 as a shortcut to fire my action . I have implemented this for Alt + F3 and some other shortcuts . But in this case , Alt + F7 is already used in the Netbeans Platform to find usages . ... | Add Alt + F7 as shortcut to an action in Netbeans platform |
Java : How is one supposed to document Java Record parameters ? I am referring to the parameters that end up becoming constructor parameters , class fields.I tried : but IntelliJ IDEA flags @ params as an error . I could n't find an online example of how this is supposed to work . The closest discussion I found is http... | How to document Java Record parameters ? |
Java : Against this pattern designThe only , I guess , with method ( ) in Base I can get the specific type.Are there more benefits ? <code> interface Base < T extends Base > { T method ( ) ; } interface Base { Base method ( ) ; } | What is the benefit of this design pattern ? |
Java : The javax.activation.MimeType class does not compare intuitively ( to me ) due to a lack of an overridden equals-method . Consider the following snippet ; It seems to me that a and b are equal in every aspect and that a.equals ( b ) should return true.Is there a reason that this class does not implement an equal... | Why does javax MimeType not implement equals ? |
Java : This question goes from my previous post in here.. Before I post my question , I am pasting the contents from oracle docs ; My understanding of type erasure when overriding is involved is as follows : if after erasure , the signature of m1 and m2 are same , then then they are considered overridden.so in my previ... | how does erasure handles overriding scenarios in Java ? |
Java : This question may be a little bit subjective , but I 'm just trying to follow the best programming practices for organization of code.I have a class Polynomial that makes a lot of reference to the class Rational , and in many different methods it uses a Rational value that is equivalent to 1 , 0 , or -1 for comp... | Java Code Organization : Where to keep instance of static class |
Java : I really do n't know how to explain this error properly ... It started when I added this method to my controller class : And I 've confirmed that without this method ( which is called on by a class , on start up of the program ) I do n't have an error.My error ? When I run from eclipse , the programe starts to l... | Bizarre Java error/bug : Stack Overflows , null pointers and double locking |
Java : I have a Java class with multiple `` type '' values , and a class which can take one of those types.I 'm trying to change the implementation of the constructor depending the Type enum using Java 's type system , but ca n't find any information on how to do it.Is something to this effect possible in Java ? Like i... | Java function signature accept single enum value |
Java : Having this method : Can I access the static variables of the class ? <code> readAllTypes ( Class clazz ) { ... } | Can I access the static variables of the 'Class ' Object ? |
Java : I 'm new to programming and Java . I 've noticed that , in the Java API , there are methods with strange assignments inside if statements . Here is an example from the Map interface : Is there some sort of benefit to nesting the assignment this way ? Is this purely a style choice ? Why not just do the assignment... | Why does Java API have seemingly strange assignments inside if statements ? |
Java : I have an swing panel with a JLabel inside of it . The JLabel looks like this : However it displays in the UI like the following : Bar Foo BarFor some reason , the first line just disappears . If I take out the slash or remove the html tags , it works as expected . Is there a way to make the first line show up w... | Why does JLabel not display '/ ' when it is the first character ? |
Java : The following simple examples cause compile-time error . But It 's not clear why. -- and -- DEMOBut the following works fine : Does it allow to tranfer control to the only while , for or do statement ? It does n't say in the JLS . What it actual says is : A continue statement with label Identifier attempts to tr... | Labeled continue statement within while loop |
Java : Good ol ' JOptionPane contains a plethora of static methods . There are many combinations , yet to change certain options ( like buttons ) you still must specify other optional arguments - often defaults ( like a null icon ) . This does n't lead to easy to read code.Moreover the methods are n't particularly cons... | Does anyone know of code that wraps JOptionPane using the builder pattern ? |
Java : I 'm looking for a regex that will split a string as follows : with the output resulting in : The string is split at every character . However , if there are digits next to each other , they should remain grouped in one string . <code> String input = `` x^ ( 24-3x ) '' ; String [ ] signs = input.split ( `` regex... | Regex for splitting at every character but keeping numbers together |
Java : In the life-cycle of my application , I have to re-create an ArrayList that contains other ArrayLists of objects ( reading them from storage ) . The ArrayList is always assigned to the same data member in a class , essentially leaving the older ArrayList-of-ArrayLists dangling ( unreference-able or inaccessible ... | Does this form of memory management make sense at all in Java ? |
Java : I have an IDevice interface and two enum realizations of this interface : AndroidDevice and IosDevice.The issue is : I want to use latent typing and call values ( ) method on an interface reference : So I have to add public IDevice [ ] values ( ) ; to my interface : But it does n't work . Eclipse asks me to remo... | Latent typing using interface and Enum |
Java : The following code compiles and runs successfully without any exceptionshould n't the line ArrayList < SuperSample > ssList = ( ArrayList < SuperSample > ) o ; produce a ClassCastException ? while the following code produces a compile time error error to prevent heap pollution , should n't the code mentioned abo... | should n't this code produce a ClassCastException |
Java : I was writing a Sieve-type function in Clojure based on Sieve of Eratosthenes ... ..and came across an error with lists of pairs : ClassCastException clojure.lang.Cons can not be cast to java.lang.Number clojure.lang.Numbers.remainder ( Numbers.java:171 ) However , changing the marking style , giving up on cons ... | Collection of pairs in Clojure using cons |
Java : I encountered with the case when I need to convert List < Book > to Map < String , Book > and the only solutions I can find is how to do Map < String , List < Book > > .The class itself looks the following way ( I ommitted getters/setters and constructors ) : I want to map all books by certain unique keys , so p... | How to create List < T > to Map < String , T > instead of Map < String , List < T > > ? |
Java : What 's the advantage of this OpenJDK line number 1455.Code snippet : Notice that , although a reference to private final char value [ ] is copied to the local val for access inside the loop , its .length field is still accessed through value , not val.I suspect `` performance '' to be the answer ( e.g . it is f... | Why copy a field reference to a local before using it in a loop ? |
Java : when you have a method , I understand that it makes sense to declare it generic so that i can take generic arguments . Like this : But what exactly is the idea behind making a whole class generic if I can simply declare every method generic ? <code> public < T > void function ( T element ) { // Some code ... } | What is the point of making a class generic ? |
Java : Its pretty basic UI , but I can not setup the JCheckBox buttons so that they are placed immediately after one another ( vertically ) without any spacing . How would I reduce the spacing seen below ? <code> JPanel debugDrawPanel = new JPanel ( new GridLayout ( 0,1 ) ) ; JPanel eastPanel = new JPanel ( new GridLay... | Remove huge gaps between check boxes on panel |
Java : What is the best way to put javascript/html/css code in the maven repository , so that is easily usable by java projects.Is there a way to do it such that the included project can be easily made `` web-visible '' by the including project ? For example assume I write a very useful tricks.js file an put it in the ... | best practice : how to host server-side code in the maven repository |
Java : I was looking at a way to optimize some things in our code base with generic functions . There is a function with return type List < Object > which could have return type List < SpecifiedType > .Bellow is a minimalist version of that function called function . It takes a parameter type , based on it calls a corr... | Java redundant casts required in generic method |
Java : The above code will not compile without : If i remove it , I get the following errorCan someone explain this ? It seems like I am starting with and IntStream , converting to a Stream of Characters and then back to IntStream . <code> public static int construction ( String myString ) { Set < Character > set = new... | Why do I need to map IntStream to Stream < Character > |
Java : I 'm new to java ( 2 weeks ) and I 'm trying to convert a inputted string in to ascii code and trying to print the sum.I 've tried using IntStream.of ( AsciiArray ) .sum but since its a string and not an int it does n't work ( Understandably ) example of what I 'm trying to do : `` Enter a 5 letter word ( all lo... | How do find the sum of an ascii array ? |
Java : I 'm frequently running into performance issues when I XSL transform large amounts of data into HTML . This data is usually just a couple of very large tables of roughly this form : During transformation , I want to visually group the records like thisA silly implementation is this one ( set is from http : //exs... | How to avoid O ( n^2 ) complexity when grouping records in XSLT ? |
Java : I have created an API which allows users to build out queries using a tree . The tree is built from the SearchOperationRequest class.So from this example I could create a SearchOperationRequest that asks for all WHERE hidden = false AND X = 88This request is built into a specification using a generic specificati... | Build JPA Specification from tree |
Java : I 'm currently stuck on a problem from CodeAbbey . I do n't want an answer to the entire thing.This is the meat of the question : Input data will have : initial integer number in the first line ; one or more lines describing operations , in form sign value where sign is either + or * and value is an integer ; la... | Modular calculator getting data inside a String array |
Java : Stumbled upon incompatible types error cause of which I do n't understand.Why is this piece of code wrong ? <code> List < List < String > > a = new ArrayList < > ( ) ; List b = a ; // is okList < List > c = a ; // incompatible types | Generics incompatible types |
Java : I 'd like to write a java framework , that supports JRE7 as a baseline , but takes advantage of JRE8 features , if being run in the context of a JRE8 ( upwards compatible ? ? ) . ( Or maybe I have this backwards ... i.e . JRE8 is the baseline , but degrades gracefully to support JRE7 ) .Does Java provide a way t... | How do I programmatically perform feature detection in Java ? |
Java : I hope some one can help me , this is what I want to do.I have a JTextPane and I want to take a screenshot to that specific JTextPane coordinates and size , so far I can do a screenshot with the size of the JTextPane but I ca n't get the specific coordinates my screenshots always gets the ( 0,0 ) coordinates.Thi... | Coordinates of a JTextPane to make a Screenshot in Java |
Java : This is n't a major issue , but I do n't understand why this happens , so I figured I 'd post it here . This is my code : The code runs fine except for one thing . The error message Make sure to enter a number . sometimes displays after the menu , sometimes before , sometimes in the middle of the menu . This is ... | Java - Error-message displaying incorrectly |
Java : I have code that extracts some specific large ( about 15k entries ) binary serialized file archive to folder on disk.extractExact function calls for every entry in archive.after this , if I try to call Files.delete ( < archive_file_path > ) method - I will get an exception : java.nio.file.FileSystemException : T... | FileOutputStream try-with-resources does n't close file descriptor |
Java : I have two ArrayLists ( list1 & list2 ) . I would like to see if any 1 ( or more ) of the objects in list2 ( which are strings ) occur in list1.So , for some examples : However , the method containsAll ( ) does not work in this use case , as 1234 does not occur in list1 , and will result in a result of false , a... | ArrayList contains one or more entities from another ArrayList |
Java : I 've got something along the lines of the following : How do I modify that so that I can do the following instead ? <code> public class A { public void theMethod ( Object arg1 ) { // do some stuff with a single argument } } public class B { public void reflectingMethod ( Object arg ) { Method method = A.class.g... | Java reflection when a method has a variable arglist |
Java : Just curious about the directory layout for the JDK . So there are two separate java.exe files - one is in : and one is in : Why does there need to be two files ? The motivation for this question arises from some challenge I 'm having installing a program ( SQL Developer ) . <code> C : \Program Files ( x86 ) \Ja... | In the Java install directory , why are there multiple java.exe files ? |
Java : I 'm new to generics , so not sure where I 'm going wrong ... I have classes , called Cat , Dog and Rabbit , which implement the interface Animal.The following code will compileBut the following code will notThe compiler says the types are incompatible . Where am I going wrong ? UPDATEThanks for everyone 's help... | Generics - Java collection within a collection |
Java : We have this code in many places where we swap integers if one value is higher than the other . Is there a way to re-factor this code , so it can be re-used ? <code> int numerator2 = < some random number > ; int denominator2 = < some random number > ; if ( numerator2 > denominator2 ) { int temp = denominator2 ; ... | Is there a way to code re-factor swapping integers |
Java : We are looking to migrate from Maven to Gradle , and have worked through most of the challenges you would expect for replacing the parent POM concept . There is one sticky point that we have n't figured out yet . We need to specify the version of Spring Boot we are using globally , but I run into invalid build f... | How do you parameterize the Spring Boot Gradle plugin ? |
Java : Let 's say you have a Client and a Server that wants to share/synchronize the same Models/Objects . The models point to each other , and you want them to keep pointing at the same object after being sent/serialized between the client and the server . My current solution roughly looks like this : But i 'm not too... | Pattern/Library for sending objects over network , keeping pointers |
Java : I have a BigDecimal amount that I want to cast to Long if it is not null , but I got a java.lang.NullPointerException exception doing : <code> BigDecimal bgAmount = getAmount ( ) ; long totalSupplyFilterMin = Optional.ofNullable ( bgAmount.longValue ( ) ) .orElse ( Long.MIN_VALUE ) ; | Optional and casting at the same time |
Java : First I declare a class : Now I execute the expression in REPL : and it outputsBut why does n't the method *** go first ? Is n't the priority of *** higher than +++ ? And how about Java and C ? Is it the same as in Scala ? <code> class Op ( var x : Int ) { def +++ ( op : Op ) = { println ( this.x + `` +++ `` + o... | The method execution puzzle in Scala |
Java : Sample testThe strange result : Why this differs ? <code> @ Testpublic void should_be_equals ( ) { LocalDate now = new LocalDate ( 2015,01,29 ) ; assertThat ( now.plusMonths ( 1 ) .plusMonths ( 1 ) ) .isEqualTo ( now.plusMonths ( 2 ) ) ; } org.junit.ComparisonFailure : Expected :2015-03-29Actual :2015-03-28 | JodaTime : plusMonths ( 1 ) two times differ from plusMonths ( 2 ) |
Java : I have a little issue with my Collision Detection System for a Game.In the game are several structures which connect to each other . However they should not connect when there is another structure in between them.For some weird reason it sometimes fails to connect to directly adjacent structures when there is a ... | Collision Detection Issues |
Java : A Sample can be deleted if status is S or P. I have this tests : Should I go further ? How should I test when the sample ca n't be deleted ? For example : Is this test useful ? What about the test naming ? Would be this logic tested enough ? <code> @ Testpublic void canBeDeletedWhenStatusIsP ( ) { Sample sample ... | Should I test cases in which nothing is expected to happen |
Java : I have added a chart in AnchorPane , and I want to get the bounds of its plot ( chart-plot , I have marked it with cyan color ) , so that I could add some texts on top of it , but I should know its exact bounds according to its ancestor ( s ) . If I do it manually , I may fail when the paddings ' size of the nod... | How to get node bounds according to its specific ancestor in JavaFX 8 ? |
Java : I have two questions : Question 1 : Is this in O ( n ) ? Does it matter how many loops ( not nested loops ) are in method1 ? Question 2 : What if there is ainside the method1 , what function is it ? <code> public static void method1 ( int [ ] a , int [ ] b ) { int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < a.le... | Confused about Big O notation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.