text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
Java : I have a Reactive Springboot application using Spring WebFlux . I 'm trying to connect to my /var/run/docker.sock Unix Domain Socket to query some information.From my terminal , I am able to fetch all running containers using the following command.I am following the Project Reactor guide , found here to create a... | How to connect to docker.sock using Netty ? |
Java : Why is in the first case SomeClass only instantiated once , but in the second case n-times , where n is the number of elements in the stream ? The method `` method '' in this case return the object itself ( = return this ) .So in the first case the list contains only one object , but n-times . In the second case... | Difference between normal instantiation and instantiation including method reference |
Java : I 'm attempting a simple regex execution . Essentially I want to determine if I 've got special characters in my string and if so check each character of the string for two specific characters i.e . hypen and dot.I seem to be having a problem in the first bit which involves determining if I 've got special chara... | Regex test failing - Java |
Java : I have the following function that itterates over an array , calls a method on each 'Refund ' object that returns a BigDecimal that contains some value e.g . 20.45 : The problem is that it always returns ' 0.00 ' . I know for a fact that the array that I 'm passing is not null , and the values that their 'getAmo... | How to add to a BigDecimal |
Java : I 've been struggling reading the javadocs to determine how to use lambdas to elegantly combine a list of rows of one type into a grouped-up list of another type.I 've figured out how to use the Collectors.groupingBy syntax to get the data into a Map < String , List < String > > but since the results will be use... | How to use Java lambdas to collect elements in a list of a new type ? |
Java : One can load a class dynamically using this method of java.lang.Class : According to the JavaDoc , the second parameter is used to control the timing of class initialization ( execution of static initialization code ) . If true , the class is initialized after loading and during the execution of this method ; if... | When should classes be initialised - at load time or at first use ? |
Java : I 'm trying to understand this regex , can you help me out ? I do n't really understand the meaning of DOTALL : ( ? s ) why the double \\ before } ? what does this exactly mean : ( .+ ? ) ( should we read this like : the . , then + acting on the . , then ? responding to the result of .+ ? <code> ( ? s ) \\ { \\ ... | regex that i do n't understand |
Java : I am counting votes for electronic election and I have only one party in my initial version . There will be different threads per voter and the threads will update the votes count of a given party.I decided to use ConcurrentHashMap , but the results are not what I expected ... The result is different every time ... | ConcurrentHashMap does not work as expected |
Java : The answer to this question explains the cause for the ambiguous constructor problem , but if I actually want to construct a third-party object which contains such constructors , and I want to pass the argument to be null , can I construct the object anyways by somehow telling java which constructor I mean ? In ... | Is there a way to explicitly specify a constructor in Java ? |
Java : Consider the following : Notice that java.lang.Class does not implement the hashCode ( ) method itself , but inherits it from java.lang.Object implicitly . I verified this in JDK 1.8.Is java.lang.Class safe to use as a key for a java.util.HashMap ? Will myMap.get ( Foo.class ) always return the values which I pu... | Will the use of Class as key for a HashMap cause undesireable effects ? |
Java : Why does the following code compile cleanly without any warnings , even with xlint : all ? running : results in a clean compile without any warnings ( unchecked , etc. ) . What is the type parametrization of the instance of the generic class A that gets 's created on the first line and what on the second ? And h... | why does this compile without any unchecked type warnings ? |
Java : I have two models , a List < ModelA > and I want to convert it to a List < ModelB > . Here are my models : Actual solution : But I think there is a simpler solution , do you have any idea how can I do it in a single stream , or simplify it somehow ? EDIT : I want to clarify that I can not use java9 and I need to... | Java-8 : stream or simpler solution ? |
Java : Example : I have some source code , FooBar.javathat gives me FooBar.class.Why does the JVM command line API take FooBar instead of FooBar.class ( working on UNIX FYI ) ? <code> javac FooBar.java | Why do you remove .class when executing on the JVM ? |
Java : One of my ES nodes has failed because of java.lang.OutOfMemoryError : Java heap space error . Here is the full stack trace from the logs : Because of the exception above , I am getting master_not_discovered_exception when I am hitting any of ES APIs.Question : Can anyone tell me the next steps that I should perf... | Elasticsearch : restart node after java.lang.OutOfMemoryError : Java heap space |
Java : Please compare two ways of setting/returning an array : Both generate distinct bytecodes and both can be decompiled to their former state . After checking the execution times via profiler ( 100M iterations , unbiased , different environs ) , the time of _1 method is approx . 4/3 the time of _2 , even though both... | preferred way of setting/returning arrays |
Java : I was experimenting with a Java port of some C # code and I was surprised to see that javac 1.8.0_60 was emitting a getfield opcode each time that an object field was accessed.Here is the Java code : As reported by javap , javac 1.8.0_60 produces the following bytecode : Note that a getfield opcode was emitted b... | Would it be legal for a Java compiler to omit getfield opcodes after the first access ? |
Java : I am relatively new to Android/Java . Thanks to Stack Overflow , I was able to learn a lot from the questions asked here . However , I am now stuck on this problem.I have a password input AlertDialog that pops up when we start the app . It reads the password from the EditText and compare this with the one stored... | Showing multiple AlertDialogs |
Java : I 've been doing some code archeology in some odd code and I came across something similar to this : The thing that struck me was that there was n't an unbounded wildcard type on Inner 's usage of the Outer type ( the < U extends Outer > bit ) .What is the implication of using Inner < U extends Outer < ? > > vs.... | Understanding Raw vs Unbounded Wildcard in Static Nested Class Type Definition |
Java : I am trying to move an object to the end of the list if it has a boolean flag set to true . The following works where I am taking the route of deleting it and adding it back . Is there a better more elegant way to do this in Java 8 ? I have to work with that boolean flag to identify if object needs to go to end ... | Elegant way to move Object to end of list |
Java : I need to convert following : to where keys of outer map ( mapOfMaps ) are redundant ( for this operation ) . So basically , I can just use mapOfMaps.values ( ) .stream ( ) to start with.And for each map object e.g . : { `` apple '' : '' 1 '' , '' orange '' : '' 2 '' } I need to convert it to a list : { `` apple... | Most efficient way to convert/flatten entire map to list ( keys & values together , not separately ) |
Java : Here I have two arrays of integer ( primitve , Wrapper ) type but I have got different result forinstanceof operator see the line number 2 and 4 line no 4 will compile successfully and give result true but in case of line 2 , why does it result in a compilation error ? From line 1 and 3 it is clear that the two ... | instanceof operator in case of primitive and wrapper type array |
Java : I am using QAF for my automation project . I have project specific meta-data which has group SMOKE , regression , P1 and author with x , y , z name.I want to run only `` smoke '' group and author with `` x '' or `` y '' . Is there any solution for these ? <code> SCENARIO : SampleTestMETA-DATA : { `` description ... | How can I filter testcases using custom meta-data in QAF ? |
Java : My whole rest service stops working when I 'm adding this code : It does n't really say why either , all I 'm getting is : And a bunch of errors saying `` caused by previous errors `` I must have done something really wrong here , are there any proffessional JPA enthusiasts that can help me out a little bit here... | JPA rest stops working when trying to upload blob |
Java : File name : B.javajava B.java runs without errorjavac B.java gives a compile error : class A needs to be declared in a file A.javaI understand that a java file can not have more than one public class , but why can a java file run without error using the java command when you get compile errors for the code using... | Java File runs with java FileName.java command but does n't compile with javac Filename.java |
Java : If there are two methods like add ( int , long ) and add ( long , int ) , such call add ( 10,10 ) would be considered as ambiguity.But what if we have such example , why is it still considered as ambiguity ? ? I want to know how the compiler decided that it is ambiguity ? while ( in my mind ) it should n't becau... | Theoretical inquiry about overloading and type promotion in java |
Java : I 'm a bit confused . On the first iterations of fill loops I see some regression in filling time when using initial capacity for ArrayList vs without using initial capacity.According to the common sense and this question : Why start an ArrayList with an initial capacity ? it must be absolutely inversely.It is n... | Some regression when using initial capacity for ArrayList on the first iterations |
Java : I realized today that this compiles and runs fine : The two handle methods has the same name , and same number and type ( ? ) of parameters . The only difference is that the second handle method has a stricter generic bound . IDE does not complain at all , and the code compiles fine . At run time method is selec... | Is generics bound part of method signature in Java ? |
Java : Out of curiosity I wrote Hello World and set a break point on my print statement.When the break point was hit , I pulled up Task Manager in windows to see how many threads were allocated by that JVM process . I was shocked to see 22 . Why are there so many threads spawned for this simple program ? <code> public ... | Why does my single threaded hello world app use 22 OS threads ? |
Java : I have created a method to create a 128 bit UUID string , I now want to check if this is a prime number or not . I cant put the string into an int because it is too big . Can anyone suggest how I would go about checking ? This is the code I have used for creating the UUID <code> public static String uuid ( ) { U... | Checking if UUID String is Prime |
Java : I am trying to sort an array in ascending order and I came across a problem . The code sorts the array but it takes the last number and places it in the first position of the array . So for example when ordering 2,3,4,1 the output is 4 , 1 , 2 , 3 . How do I take the number 4 and move it behind the number 3 ? Ou... | Array sort leaves one element in the wrong position |
Java : My goal is to generate a pseudorandom String consisting of 500000 characters out of a small selection of characters . This is my loop for adding characters to the String : Unsurprisingly this is very slow , so I am looking for ways to get this to perform the > least slow < possible . <code> String alphabet= '' A... | How can I optimize my code for generating a pseudorandom String for high speed in Java ? |
Java : I have the following entity : I want to get some entities with additional column from the database.To do this I created a simple Pair class.Then I prepared a query in JPQL that creates the expected result.The query returns correct results , but there is a problem with additional queries.Therefore , I have some q... | Why does placing an entity in the POJO class using `` select new '' in JPA cause an N + 1 problem ? |
Java : Is this code bad practice as the method show ( ) is deprecated ? Is it okay to override here ? <code> public class Window extends JFrame { public Window ( ) { // Do things . } public void show ( ) { // < - Comes up with a warning as deprecated code . // Do other things . } } | Is it bad practice to override a deprecated method ? |
Java : Let us have a stream of objects , resulting from a sequence of operations ( e.g . mapping , filtering , flatmapping , etc. ) . Now I want to do a certain operation on them , but only if a given predicate is true . Otherwise I want to immediately return something else.A simple example . I have a stream of differe... | Is it possible to define an optional flow or exception-like behaviour in Java 8 streams API ? |
Java : I remember a couple years ago I was using static initializers to call class-level setup operations . I remember it having very bizarre behaviors and I just decided to steer clear from them . Maybe it was because I was messing up the top-bottom order or being a newbie . But I am encountering a need to revisit the... | Legitimate uses for static initializer ? |
Java : In Java8 , what is the type of the following lambda ? ? ? That is a function that takes no arguments and returns nothing.Stated differently : What should I replace the question marks with ? In Scala , this would be a Function0 [ Unit ] I think , but I do n't find anything alike in Java . <code> ( ) - > { } publi... | What is the type of ' ( ) - > { } ' in Java 8 ? |
Java : I 've encountered an `` unrecoverable stack overflow error '' that I ca n't figure out . From the docs : you need to create an interface object ( of any class ) and make it known to JavaScript by calling JSObject.setMember ( ) .Here 's the Java code sharing and using the interface object : And here 's the JavaSc... | Unrecoverable stackoverflow error when making upcalls from JavaScript to Java |
Java : I have three Integer variables , where I am not allowed to change to primitive int and I need to check if at least one of them have a value greater than 0 . Is there a shorter / cleaner way to rewrite my code below : <code> Integer foo = // null or some valueInteger bar = // null or some valueInteger baz = // nu... | Shorter way to check for not null for multiple variables |
Java : I have a list of roles in a database . They are of the formSo each role has an entry based on read/write permission.I want to convert the roles into a POJO which I can then send as JSON to a UI . Each POJO would have the role name , and a boolean for read or write permission.Here is the RolePermission class : I ... | How to convert a list of strings into a list of objects ? |
Java : I have come across below strange syntax , I have never seen such snippet , it is not necessity but curious to understand itAbove code gives output as strangethanks <code> new Object ( ) { void hi ( String in ) { System.out.println ( in ) ; } } .hi ( `` strange '' ) ; | Java strange syntax - ( Anonymous sub-class ) |
Java : I wrote my own Stack class ( for the relevant code , see below ) . In the next ( ) -method I am forced to cast current.item to Item , but I do not know why . The type of current.item should already be Item and thus casting should not be necessary - but if I do not cast it , I get an error . <code> public class S... | Cast is forced when using generics in Java |
Java : In this code , T can be A , B , C , or D , but Eclipse shows that it is D.Is there any rule for how type inference is done and why it selects D ? <code> static class A { } static class B extends A { } static class C extends B { } static class D extends C { } static < T > void copy ( List < ? super T > dst , List... | How does Java handle ambiguous type inference for generics ? |
Java : I 'm trying to add specific values to a map in Java , where the key is quite complex , but the value is a simple Double.Currently I 'm using , where foos is an instance of java.util.TreeMap < Foo , Double > , and amount is a Double , code like : but this looks quite dirty in that I have to reinsert the element ,... | Adding a value to terms in a Map |
Java : Can anyone explain why there is an untyped conversion warning on y assignment line ? Note that there is no warning on either x or z assignments . <code> public class Entity < T > { @ SuppressWarnings ( `` unchecked '' ) public < TX > Entity < TX > typed ( Class < TX > type ) { return ( Entity < TX > ) this ; } @... | Unexpected unchecked conversion warning |
Java : The specific use where I thought of this problem is as follows , but it 's much more generalized.I have a custom JFrame class which also serves as an ActionListener for its components . So my constructor looks something like the following : My question is , how does this actually work behind the scenes ? If the ... | How can `` this '' be referenced/processed before the constructor has concluded ? |
Java : So I have a javadoc that looks like this ( censored for the public of course ) : So the reason for this is that doing */ in my example will end the javadoc . Having the braces confuses the @ code tag.The problem is that the generated javadoc shows the HTML entities codes instead of the actual character that I wa... | How do I write a block comment in my javadoc example ? |
Java : Sir i am trying to print array 's 0th element but i can't.Here is my code when i am trying to print arr [ 0 ] its return blank but when i print arr [ 1 ] it returns the 0th element value . would you please help me to find my error . <code> import java.util.Scanner ; public class prog3 { public static void main (... | Unable to print array 0th element |
Java : Hello I am trying to understand the code I have written and why does it print the output belowprints meASSUME THAT the given matrix is not symmetric here . How can I modify this code to give me back saying if the matrix is symmetric or not only once . <code> public void isSymmetricNow ( int [ ] [ ] matrix ) { fo... | Void method printing two times |
Java : I 've got a problem , I 'm getting a `` Dead Code '' warning in Eclipse and I really do n't know why . The code is from my Connect Four project , to be more precise it 's from the Class that checks if somebody has won . This method checks all the horizontal winning possibilities for red . The code is the followi... | Where does the dead code come from ? |
Java : I 'm writing a test class for my GiftSelector class using JUnit in BlueJ . When I run the testGetCountForAllPresents ( ) method , I get a NullPointerException on the line : The strange thing about this NPE , is that it rarely appears when I run the test once , but often appears the second time I run the test . I... | Why Am I Getting An NPE That Only Appears Occasionally When The Program is Run ? |
Java : I 'm a newbie to Android and Java so please be nice : ) I have an EditText in my application which is used to search for a particular string in a String [ ] My code works well , but not as I want : This code produces these results : if I search for `` table is '' = > allProd_sort will be [ the table is brown ] b... | Improve search in array |
Java : I tried this : But I get an `` incompatible types '' error : As far as I know all enums inherit from Enum . Why is my enum incompatible to Enum ? <code> public static enum Types { A , B , C } Class < Enum > e = Types.class ; found : java.lang.Class < id.Types > required : java.lang.Class < java.lang.Enum > Class... | How to declare a variable which can contain only enum classes ? |
Java : Suppose you have a class that is frequently ( or even exclusively ) used as part of a linked list . Is it an anti-pattern to place the linkage information within the object ? For example : An often-cited recommendation is to simply use a generic container class ( such as java.util.LinkedList in Java ) , but this... | Is linkage within an object considered an anti-pattern ? |
Java : I 've come across an interesting bit of Java code that IntelliJ flags as an error , but which javac accepts as legal . Either IntelliJ is wrong , and the code is legal , or the compiler is `` wrong '' , whether due to a bug or an intentional relaxation of rules.I like to think I understand the Java type system p... | Inheriting raw types w/ conflicting generic super-interfaces |
Java : I 'm wondering whether it 's a good practice to produce the code which being used like this : Here , TemplateProcessor contains only one public method . It seems the code above can be expressed with a static method , but I would like to avoid that . The reason is simple : object may contain encapsulated state , ... | Is this appropriate to create a class with one method ? |
Java : I am working on a business logic where I need to divide and multiply BigDecimal variable to produce business result but I am facing the problem to maintain the accuracy . Actual business I ca n't put here so I created a sample program and included here . I need to use only BigDecimal so I am strict to it but I a... | Maintain Accuracy Level Maximum |
Java : According to information from official site I added latest depedency and started to develop.First I created model with data I 'm interested : second step was to add service : Third one was to add implementation : But there is an error : Here is full error log trace <code> public class Data { String parametr1 ; /... | Retrofit usage in with API in Java |
Java : I need to inherit android.support.v4.view.ViewPager and two constructors . In Java , it is done by : I have searched on Google and here for a while , and some people suggested to implement this in Scala like this : The above Scala code compiles , but it it seems that the apply method is not invoked correctly whe... | Call different Java parent constructor from Scala with Android |
Java : I am trying to save the groups in a string to an array so that I can use them in individual variables if I need to . For this I use split but for some reason I only get the full string in the first position in the array : ultimate_array [ 0 ] . If I want to use ultimate_array [ 1 ] I get an exception like `` out... | split not working correctly |
Java : I have some code as follows : Specifically I want to take the values from the list and put them into the map . That all works perfectly . My concern though is with ordering.For example if the list has : How do I ensure that the final map contains : Instead ofThe incoming list is ordered , stream ( ) .filter ( ) ... | Using java streams to put the last encountered value into a map |
Java : I have code in my project that looks like this : Eclipse gives a warning for the cast in addBar that the cast is unsafe . However , am I correct in assuming that the cast will not throw given the restrictions that I have put on the type parameters , and therefore the cast is indeed safe ? <code> public interface... | Is this cast in my generic method safe ? |
Java : Are the two statements equal in Java ? <code> //code 1Object o1 [ ] = new Class [ ] { iface } ; //code 2Object o2 [ ] = new Class < ? > [ ] { iface } ; | Is 'new Class [ ] { iface } ' and 'new Class < ? > [ ] { iface } ' the same in Java |
Java : I have a Set of some objects . I need to get the two min objects from the Set.My example is as follows : In my example I can get the min object from this Set based on the value attribute.So , I need to get the two min values using Java stream operations.The answers should be fast because in my real program I cal... | Get the two min objects from a set using Java stream |
Java : Here 's my sample class , that compiles ( and runs ) with version 1.6.0_14 of Java : I know that you 're supposed to only have one public class per file in Java , but is this more of a convention than a rule ? <code> import java.util.List ; import java.util.ArrayList ; public class Sample { List < InnerSample > ... | Why is javac not complaining about more than one public class per file ? |
Java : please , I want to know the difference between writingandand how would that affect the code <code> public class Something < T extends Comparable < T > > { // } public class Something < T extends Comparable > { // } | Difference in java generics |
Java : I managed to use a spinner in my code and wanted to change the textColor of a certain text in the MainActivity file trough that spinner , but he is located in another class file - Einstellungen.Is it possible to change the textColor in the current activity from another activity ? This is the main_activity.xml wh... | Change android : textColor with a spinner |
Java : User sends me byte / short / int / long value . I have to send it as the part of POST HTTP request and I have to send number as String.So right now I do the next : I 'm looking for faster alternative for Because this flow creates char [ ] , String and byte [ ] objects . While I need only byte [ ] . I wonder if t... | Is there is a faster alternative for Integer.toString ( myInt ) .getBytes ( US_ASCII ) ? |
Java : In Java , we use Interface to hide the implementations from users . Interface contains only abstract methods and as abstract methods do not have a body we can not create an object without constructor . Something like thisMy question is why Java allows creating an array of object Interface and where someone might... | Array of Data Type Interface |
Java : I have a created a simple Login Webservice in Java and I am calling it from the Android code . I am passing two String Parameters to the Webservice . But they become null in the Webservice.The Web service is hosted on Localhost Tomcat serverThe WSDL file is : I am new to both Android and Creating Web Service . I... | Error in Callin Java webservice from Android using k-Soap |
Java : I have a list of objects of class A defined as below : Now I would like to create a stream which contains elements of both sOne and stwo . Is there a way to do it in Java 8 ? <code> class A { private Set < String > sOne ; private Set < String > sTwo ; // Constructor , getters and setters } | Joining 2 streams from same object in java |
Java : I had recently a discussion about the use of non-counter related conditions in for-loops in Java : Does anyone know if there are any `` official '' conventions for for-conditions like this ? In my opinion it 's easier to read compared to an equivalent while-loop because all loop-parameters are together in the fi... | For-loop condition conventions |
Java : I get a ClassCastException error when I run this because of the implicit cast of d to a double when I run the code . However , if I change reference to d in to Object [ ] then it ca n't be a parameter to the set function . If I change the set function to accept an Object [ ] then everything works fine , but then... | Returning an Array from a generic class |
Java : I have came across the piece of code : and we can use this to create an instance of HashMap , like this : Now the question is the method newHashMap is called without passing the required type ( in this case its ( String , List < String > ) , but still java is creating the correct type . How ? I 'm confused here ... | Generics type parameters getting bounded , without passing real type |
Java : QuestionWhy does Spring 's RestTemplate use an excessive amount of heap ( particularly the G1 Old Generation ) when sending a file.ContextWe observed the RestTemplate to consume excessive amounts of memory when sending files via POST requests . We used Spring 's WebClient as comparison and it behaves completely ... | Why does RestTemplate consume excessive amounts of memory ? |
Java : How the JVM chooses which method to execute ? Is it true that the choosing process is divided into 2 parts . First while compiling the JVM looks for a candidate method to execute . It selects the required signature into the declared object class ( not the effective one ) . Once it selected the candidate signatur... | Methods selection with Overloading and Overriding |
Java : I am new using GlassFish Server and WS . I just deployed a Web app . generated with maven having this web.xmlI click on the Web Application LinksI have this class in the application : It seems that the WS is deployed since I saw it in EnginesI can access the spp . http : //localhost:8080/iberiafleet/ But I do n'... | GlassFish Server deployment |
Java : My application structure is likeI created an annotation as below : -Then created a Sample Interceptor : Then I created a GuiceModule as below : - } Class in which I am using the above annotation is I have a RestModule using which I am binding SampleClassForInterceptor as followsNow I have a bootsrap class in whi... | Not able to inject java object while writing Annotation based Method Interceptor using Guice framework |
Java : Im trying to do - What I expect to happen is to now have 2 separate readers on the file pointing at different places . However , the buffReader returns null on the readLine , while the scanner seems to work fine . Is it possible for me to have 2 readers like I want ? <code> BufferedReader br = new BuffereReader ... | Scanner constructor causes bufferedReader to return null |
Java : I 'm trying to hide an implementation of a class I do not own . I 'm wanting to do this my extending the class and implementing an interface of my own . Here is how an instance of the class I need is created : QueueInfo is the class I do not own . To get an instance of this object , I have to use an admin object... | Java OO : Is this even possible ? |
Java : I am using the below code . The first line is giving java.lang.NumberFormatException , and the second is giving java.lang.NullPointerException . I 'm unable to figure out why . <code> int intValue =Integer.parseInt ( null ) ; Double double1 = Double.parseDouble ( null ) ; | Why do different Exceptions occur ? |
Java : I 'm attempting to count the number of times an Int is seen in a field within a List of Objects.This is the code I haveyet it is n't ideal , if more ratings are added ( say 20+ ) then you 'd have a bunch of doubles being created , and it 's not maintainable.I know I could do something with a Stream if I had a li... | How could I improve this List iteration with a Stream ? |
Java : Reading the JAVA 13 SE specification , I found in chapter 5 , section 5.1.7 . Boxing Conversion the following guarantee : If the value p being boxed is the result of evaluating a constant expression ( §15.28 ) of type boolean , char , short , int , or long , and the result is true , false , a character in the ra... | Is caching of boxed Byte objects not required by Java 13 SE spec ? |
Java : I tried something in my code and it didn´t work ( the error when compiling was `` The local variable fundo is never read '' ) . I´ve made some changes and it worked , but I would like to know why it didn´t work in the first place.I have a class called Setor , in my code I´m trying to create an object from that c... | Why can´t I create a class object within a method from a different class in Java ? |
Java : ( I 'm using Eclipse Luna 4.4.0 , JDK 1.8.0_05 ) I 'm making a game , and the topology of the game world can be roughly broken down into World - > Level - > Tile , where a Tile is a a small unit of terrain . I have three projects set up , one which holds some base classes for those structures , and the other two... | This convoluted generics pattern crashes Eclipse - can I make it work ? |
Java : When I use this code at my home PC , it gives the output as `` output1 '' , Butwhen i use the same code at my office PC gives a different output as `` output2 '' .code : Output 1 : C : \Users\admin\AppData\Local\Temp\Output 2 : C : \Users\admin\AppData\Local\TempWhy there is a difference in output ? <code> Syste... | Different Results on Different System |
Java : This is my second programming class and I am new to Java . I have been working on my first assignment and it involves classes and methods . I know very little about these topics and find myself lost . My assignment asks me to create a RPN calculator that asks the user for two numbers and an operator . The calcul... | RPNCalculator Code Confusion |
Java : I am new in Java8 , and I created this piece of code that is working finebut under my understandings this piece of code should also work fine , but is not the case and I am wondering why <code> userService.getClient ( ) .findUsersByMarkets ( marketIds ) .stream ( ) .filter ( us - > ! alreadyNotifiedUserIds.conta... | Java8 .getMethod ( ) vs : :getMethod |
Java : I am facing some problems with garbage collection while generating an application in java , where I use Stream.map to trim all the elements in the list . The instances of anonymous lambda class exist in the heap dump even though the instance of the enclosing class is 0 as shown in the snap of visual VM.The Lambd... | Java lambdas heap dump - Instance of lambda not getting garbage collected |
Java : I 'm working through myself Oracle 's JavaFX tutorials . After doing Swing for many years ( a long time ago ) I 'm fascinated by the new smart features , incl . properties . I was surprised to see that these examples ( e.g : https : //docs.oracle.com/javafx/2/ui_controls/table-view.htm ) do n't use them in a way... | JavaFX Displaying properties in controls |
Java : This happens in both C # and Java so I think it 's not a bug , just wonder why.According to this page , the lower case of `` '' is `` '' , they should be the equal when comparing with IgnoreCase option . Why they are not equal ? <code> var s = `` '' ; var lower = s.ToLower ( ) ; var upper = s.ToUpper ( ) ; if ( ... | Case-insenstive string comparison strange behavior |
Java : I have 2 Lists : Does anyone know how can I merge those 2 Lists to one List containing all the employees from both lists grouped by `` PersonalNumber '' and keeping the order of the elemets in newList ? newList comes from the Database with a predefined sorting , and I need to keep it that way , so I ca n't sort ... | Java 8 : merging two Lists containing objects by Id |
Java : The standard method of implementing singleton design pattern is this : I was wondering if you could also implement it like this : and if yes which version is better ? <code> public class Singleton { private static Singleton instance = new Singleton ( ) ; public static Singleton getInstance ( ) { return instance ... | Implementing Singleton Alternatively |
Java : I am comfortable with functional languages and closures and was surprised by the following error : `` Can not refer to the non-final local variable invite defined in an enclosing scope '' .Here is my code : As I understand it , referencing invite in the TimeTask instance is an error because that variable is not ... | What 's the Java way of handling closures ? |
Java : Please what memory tuning advise would you suggest given the GC log below with a system currently running on these params , taking into consideration the Machine recieves high frequency data that takes a about 6ms to process.Thanks in Advance.GC Logs <code> java -Xms4144m -Xmx4144m -XX : +UseParNewGC -XX : +CMSC... | JVM Memory Tuning Advice |
Java : I 'm trying to parse a json file that looks like thisThe code I have is currently this : I am getting an error : Is there something special I need to do in order to read `` < `` as String ? I 'm reading the file into a BufferReader with StandardCharsets.UTF_8 like this : Edit : I actually do need defaultTyping f... | Deserializing JSON with special characters into a string |
Java : I want to dynamically set an integer variable using a hexadecimal value , but when I use Integer.parse ( hexValue , 16 ) it gets a different value from setting as int a = 0x04A7D488For example : Why do I get different values ? How can I dynamically set variable a with value 0x04A7D3B8 ? Note : I 've discovered t... | Why does this hexadecimal value gets different decimal value ? |
Java : I have written : And sonar says : New : Squid : S2183 Severity : CRITICAL , Message : Remove this useless shift Could anybody tell me why ? Is that only the fact that there should be no calculations on literals , even if it adds to readability ? <code> public static final int MY_GREAT_COLOR = ( 91 < < 16 ) + ( 1... | SonarQube Java Analyser , rule S2183 , why should I remove this useless shift ? |
Java : java.util.concurrent.TimeUnit has this source : Why is n't this an abstract method like <code> public long convert ( long sourceDuration , TimeUnit sourceUnit ) { throw new AbstractMethodError ( ) ; } abstract int excessNanos ( long d , long m ) ; | Why does java.util.concurrent.TimeUnit.convert throw an AbstractMethodError instead of being abstract |
Java : I am a complete newbie at Big O and I am a bit stumped by this . I have : In my mind this would equate to Am I right or can it be simplified to N as you are doubling the inputs with n*n and halving it with i *= 2 ? <code> for ( int i = 1 ; i < n*n ; i *= 2 ) | Big O N^2 ( Log N ) |
Java : Q : Is it possible to create Stream implementation that counts their elements in a single operation rather than counting each and every element in the stream ? I came to this though when i tried to compare two methods on a list : size ( ) count ( ) Stream : :count terminal operation counts the number of elements... | Is it possible to create Stream implementation that counts their elements in a single operation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.