text
stringlengths
46
37.3k
title
stringlengths
12
162
Java : I want to select the first row in a table , order by time ( ascending ) , then delete that row . I do n't want to use two queries since there 's a possibility that another client could select that row before it gets deleted ( there will be several machines connected at once from different networks ) .I was think...
SELECT and DELETE
Java : Hi I have a question regarding a log4j logger.There is a part of the logger text I do n't quite follow.The line looks as followsI had a look but I ca n't seem to find this as a regular expression , it smells strongly like it could be though and I suspect that it will be replaced by the returned value of someObje...
log4j regular expression ? [ { } ]
Java : Id like to improove continuous delivery . I am using a Tomcat 8 and maven.I use mvn tomcat : redeploy to deploy the webapp.In tomcat documentation I found this part : Deploy A New Application Archive ( WAR ) RemotelyIf installation and startup is successful , you will receive ( ... ) Otherwise , the response wil...
Optimize continuous deployment ( cancel throu chain-of-responsibility )
Java : I have a rather central class responsible for some Utility methods . I wanted to provide an additional overload for a method which was declared as follows : Now since I do n't really like Rawtypes , I specified the collections out into the least common denominator I can expect : So far so good , this got rid of ...
Erasing Collections generics and conflicting overloads
Java : We currently use Beyond Compare 3.0 and I am quite pleased with it . However , it would be great if I could easily specify an exclusion for a specific one-time case . This is needed when I am doing a code review of some refactoring . For instance : Old codeNew code : In this case , I have hundreds of changes tha...
Is there a file diff tool that allows for exceptions ?
Java : I have integrated some HTML/JS Code into my Vaadin WebApplication by creating an AbstractJavaScriptComponent . The Component almost works as intended.How do I call the passInfo ( ) method defined in the `` connector.js '' without having to manually click the Button defined in the innerHTML of the `` chessControl...
JavaScript Scope of Vaadin 's `` AbstractJavaScriptComponent ''
Java : I am trying to use putextra ( ) and getextra ( ) but my program is crashing after implementing itGo through my code and let me know my mistakeIf I am not using getextra ( ) and putextra ( ) the code is working flawlessly This is 1st class from where I am getting the valueNow the Second class where I am trying to...
Implementing Getextra ( ) and Putextra
Java : I 've written a streams implementation that performs four simple reductions ( + and < ) on the lines of a file.At first I performed four streams , but I decided to write my own accumulator and combiner so that I could perform all four reductions in one stream . On small data sets ( 10,000,000 lines ) this reduce...
Can Java 8 streams cause a O ( 1 ) memory reduction on unbounded data to become O ( n ) memory because of the underlying ForkJoin implementation
Java : Since I could n't find a standard implementation of it I created this little class , but I think something simple as this should exist somewhere already : The purpose of it is to exchange a value between two threads ( main thread + EDT in my case ) . From the code using the getValue ( ) method it looks almost li...
How do you call this kind of concurrency related class ? And is there a standard implementation ?
Java : I have a rollback exception with hibernate on my service `` duplicateContract '' The problem is , I just ca n't debug that , there is an error with the persisted object somewhere but I have no clue ( it 's not a timeout or missing @ Transactional ) . How can I get more details for this exception ? ( maybe somewh...
How to get the SQL error origin of an UnexpectedRollbackException
Java : I found code examples in internet for reading the data from the latest version of Google Sheet as below : But I can not find any examples , to access a particular version of the Google Sheet and get a cells value in that revision.Also please let me know , if the above requirement can be completed using google sp...
How to read data from a specific version of Google Sheet ?
Java : I´m developing an application for Liferay 6.1 EE GA3.Under the control panel , we have the section Private plugin installer where we can install / deploy new portlets . I was using the panel and the section was workng correctly.Then i tried to install a custom portlet . For some reason the installation failed an...
Liferay 6.1 - Private Plugin installer `` disapear '' or is disabled in Control panel
Java : Sorry for really stupid question , I 'm learning a new language and taking this code : Why the output does not produce `` ] '' character ? Has it something to do with Unicode ? PostEdited : the variable E.c was not initialized for experimentation purpose . <code> public class Exercise01 { int i ; char c ; public...
First Ever Java Program Incorrect Output
Java : I have the following code : This works fine on my computer and on my Android device . I get strings like 0product0 etc.BUT in production , on users ' Android devices , I get strings like : Does String.format ( ) not work OK when starting with a number ? <code> int color = 0 ; int number = 0 ; // ... s = String.f...
String.format fails to format numbers on some devices ?
Java : I 'm using removeNumbers to remove all numbers in a given string with the regex '' ( ^| ) \\d+ ( $ | ( \\d+ ) + ( $ | ) | ) '' Here 's the code : Output : Is there any better way to do this ? Edit : As suggested by @ mbomb007 in his previous answer , the regex `` ( |^ ) [ \\d ] + ( | $ ) '' works as well : <code...
Regex to find numbers in a string
Java : Just trying a hands-on the java.lang.Record . I have gone through the documentation and the JEP-359 for some understanding . So upon reading about the implicit declaration of the constructor I thought of mixing it up with an existing code generation library - Lombok ! Now what I 've ended up creating as a minima...
Java Records and Lombok annotation - IntelliJ
Java : my Splash activity does n't change , it only changes if I change the name to another.For example : '' SplashActivity '' - Start with a ModificationIf I change the theme to another color , I need to rename the activity to : '' SplashActivityy '' or some other name than it was.If I go back to the name `` SplashAct...
Activity Theme is not changing
Java : i just stumbled onto this comment . in the 1.5 java source.what does this comment mean ? is it a reference to a book ? a spec ? <code> public static int lowestOneBit ( int i ) { // HD , Section 2-1 return i & -i ; }
cryptic comment in jdk source : // HD , Section 2-1
Java : Primitives are at it again , breaking rules , I learned before . Well not technically primitive but composed of them.I learned that whenever there 's no method more specific than rest , compile time error occurs as it happens here.Now comes primitives into the picture.Expected compile time errors occurs here.Now...
Primitive vararg parameters in method overloading
Java : Recently , I 've noticed , it is possible to have : Is there a reason for this ? <code> class Test { public enum Season { WINTER , SPRING , SUMMER , FALL } Season field = Season.WINTER.SPRING ; // why is WINTER.SPRING possible ? }
In Java , why is it possible to qualify an Enum Constant with another Enum Constant ?
Java : Each time our new android app released , I need to update app info on our website . So I try to update the app info automatically , by read the AndroidManifest.xml in the apk when uploaded to server.I use AXMLResource and jdom2 to get the AndroidManifest.xml and parse it.But I always get , The prefix “ data ” fo...
Java parse xml with undeclared namespace
Java : I have a simple sticker widget that allows the user to select one of the stickers upon placing the widget . My problem is that once the device is restarted , the sticker reverts to the default one . How can I ensure that the user selected sticker remains regardless of whether the device is restarted or not ? An ...
How to ensure user selected image does n't change after restart Android ?
Java : Is there any guarantee that an object will not be garbage collected while a thread holds its monitor ? e.g.In this case concretely , is there any guarantee that b will be non-null if thread2 ( ) is called while another thread is sleeping in thread1 ( ) ? Let 's just assume the whole of thread2 ( ) is executed wh...
Does Java guarantee that currently synchronized objects are not garbage collected ?
Java : I need to implement current formula.It is for scoring the nodes in a taxonomy . Basically , the score of a node depends on the amount of child nodes and their scores ( ( nodes ( h+1 ) ) is the amount of nodes on the next level and Cl ( concept ) is a set of children ) .In my usecase term frequencies are only def...
Mathematical formula to a recursive method
Java : I have some code that uses the Swing/AWT printing functionality that I want to unit test . It uses the systems native print dialog , but is there any way to get the JVM to intercept that and replace it with a mock during unit testing so that I can get a copy of the image that would be printed ? My code for print...
Unit tests for printing in Java Swing
Java : I made a Java agent which is attached to a JVM during runtime and instruments all the loaded project classes and inserts some logging statements . There are 11k classes in total . I measured the total time taken by the transform method of my ClassFileTransformer and it was 3 seconds . But the duration of the who...
How to speed up runtime Java code instrumentation ?
Java : I have one repository in two different folders ( folder1 and folder2 ) . Within repositories has a `` oldFile '' fileIn the folder1 I do the following steps : After that , in the folder2 I do next steps : In this case I want to get a merge conflictAnd I want to see pulled files . I got the example from here.In p...
JGit get pulled files
Java : I want to use CoreNLP in my Android project . But when I create a CoreNLP instance like this : The project links to the following .jar files : ejml-0.23.jar stanford-corenlp-3.4.1.jarstanford-corenlp-3.4.1-models.jarOn my desktop java environment with java 1.8.0_92 , this code runs correctly , but when running t...
'Ca n't return head of null or leaf Tree ' with CoreNLP on Android
Java : In the documentation for public Object get ( Object obj ) method in the Field class it is stated that The value is automatically wrapped in an object if it has a primitive type.and for public void set ( Object obj , Object value ) that If the underlying field is of a primitive type , an unwrapping conversion is ...
Whats the purpose of the primitive getter/setter in Field ?
Java : So , lets say I have some game , take Pong for example . Obviously , you generally speaking do n't want to mix game-logic into graphics classes , so the class for Ball or Paddle is sepearte from the JPanel which actually draws them . Ball has the movement logic for the ball , its current location , hit detection...
Is it bad practice to use swing and awt classes for my non-graphics related classes in my programs ?
Java : I have the following as AppCompatSpinner 's entries : Upon selecting Pick a time.. , a TimePickerDialog is opened and the user is allowed to choose a time . Here 's how : Upon selecting Pick a time.. the first time , TimePickerDialog is successfully opened and the chosen time is shown but when I choose it again ...
AppCompatSpinner 's entries not opening TimePickerDialog on selecting it second time . Please see details
Java : I had a coding interview over the phone and was asked this question : Given a String ( for example ) : `` aksdbaalaskdhfbblajdfhacccc aoudgalsaa bblisdfhcccc '' and an expression ( for example ) : `` a+b+c- '' where : + : means the char before it is repeated 2 times - : means the char before it is repeated 4 tim...
Finding the Number of Times an Expression Occurs in a String Continuously and Non Continuously
Java : I am designing a game engine in Java.At the core of this engine exist the two classes Asset and Attribute , where an Asset has a list of Attributes . Most Attributes need no link back up to their Attribute , meaning that Attributes can and often do appear in the lists of more than one Asset . However , there is ...
Java : Enforcing doubly linked objects
Java : I have a question about Java generics . Say I have the following interface : An example of usage : I would also like to be able to add Something < Integer > , Something < Double > , ... to the a Manager < Number > . I would say I have to change the signature of the add-function : So far , so good . Let 's look a...
Java - generics & wildcards & interface versus implementation
Java : What 's the sense of this class definition , what 's kind of class is that ? <code> class Node < K extends Comparable < ? super K > , V >
Class definition class name < >
Java : I 'm currently exploring Guice capabilities and faced a strange behaviour - when I declare variable asinjection works as expected , but when I want to declare dragon2 as interface ( it implements Creature ) , i. e. I get an error No implementation for warlock.rincewind.creatures.Creature annotated with @ com.goo...
@ Provides with @ Named does n't work for supertype declared variables
Java : Using ZeroMQ .Context and .Socket instances , I am able to push/pull messages for example below my code for a Queue like setup : My questions are : Q1 : How to implement an active / standby mode in queues ? I mean there will be 2 queues , created for one host and port , if one queue ( the active ) fails , anothe...
How to implement an active & standby queue job-processing system in JeroMQ ?
Java : I am new to java . I had a doubt . <code> class ArrTest { public static void main ( String args [ ] ) { int i = 0 ; int [ ] a = { 3,6 } ; a [ i ] = i = 9 ; System.out.println ( i + `` `` + a [ 0 ] + `` `` + a [ 1 ] ) ; // 9 9 6 } }
Why the following code does not throw IndexOutOfBoundsException , and print out 9 9 6 ?
Java : i was working on the basic java program and i found verry funny thing which i am sharing with you . foo ( ) gives output ( s==s1 ) = false and bar gives ( s==s1 ) = true.I want to know why this happens . <code> public class StringTest { public static void main ( String [ ] args ) { foo ( ) ; bar ( ) ; } public s...
Why do I get different results when comparing strings after using different concatenation in Java ?
Java : I have a code where my client send an excel file to the server . The server ( SpringBoot ) needs to 'translate ' the MultiplartFile to an excel File.From then , the data needs to be inserted into a database.However , I never need to generate an excel but rather should insert the data from the spreadsheet into th...
Save uploaded excel in database
Java : I 'm using a PostUpdateEventListener registered viaand a few other listeners in order to track changes made by Hibernate . This works perfectly , however , I see a problem there : Let 's say , for tracking some amount by id , I simply executeon every POST_COMMIT_UPDATE ( let 's ignore other operations ) . The pr...
Reliably tracking changes made by Hibernate
Java : Is it good programming practise , when dealing with multiple classes that need the same instance of variables , to create one central one ? For example : I have a class with a set amount of variablesI have another class that needs the same variablesAnd another that needs the same variables as the firstSo I have ...
Good programming practices with centralizing variables
Java : Suppose you start with an auto-generated methodAnd write a test for itThen 3 month from now you decide that a more appropriate name for the method would be changeKeyTo . You refactor your production code and end up with : Life is good , however , your test name remained unchangedHow do you deal with something li...
How to refactor test code together with production code ?
Java : Our application sends strings which then shall be localized on client side . Sometimes those are whole strings , sometimes only substring , so we have to mark them . It would be the best if it only used Unicode as it would n't require any protocol changes.Example : where 10 is length in cm but it should be conve...
Which subset of Unicode symbols should I use to mark special substrings in text ?
Java : I use two Interfaces : My problem that I want to register a Distributor in a Distributor e.g.Distributor < Object > ==register== > Distributor < String > My first thought was to change the register method to register ( Receiver < ? extends T > receiver ) . But if I want to get the Classes the receiver is intrest...
Generic Chaos Java
Java : Here is the original link , http : //electrotek.wordpress.com/2008/08/06/singleton-in-java-the-proper-way/I am asking why we can call the function doStuff this way in Java . <code> public enum YourSingleton { INSTANCE ; public void doStuff ( String stuff ) { System.out.println ( `` Doing `` + stuff ) ; } } YourS...
Singleton – the proper way
Java : I am implementing a Java application using the Swing GUI framework on macOS . When using the system look and feel and a screen menu bar , Swing automatically inserts a search field called Spotlight for Help into the first menu labelled `` Help '' of the menu bar of a frame : As my application is localized , the ...
How to insert Spotlight for Help into localized macOS applications in Java ?
Java : While investigating the subtler consequences of generational garbage collectors on application performance , I have hit a quite staggering discrepancy in the performance of a very basic operation – a simple write to a heap location – with respect to whether the value written is primitive or a reference.The micro...
What can explain the huge performance penalty of writing a reference to a heap location ?
Java : I 'm making my very own version of Java 's Stream library for fun . Here 's my class signature : Also , I wrote a basic infinite stream iterator that would generate an infinite list based on the given function : The function generate is a special case of iterate that repeats a given element forever . In the func...
Filter Function Not Lazy
Java : I have the sample code below : and the following exception was thrown My question is why I am not able to add new string to my list ? <code> String [ ] patternArray = { `` 1 '' , '' 2 '' , '' 3 '' } ; List < String > patternCheck = Arrays.asList ( patternArray ) ; patternCheck.add ( `` 4 '' ) ; Exception in thre...
List throwing UnsupportedOperationException
Java : There many ways to get a good security for REST ( easy ) services . I tried already . In this case only is a Basic Authentication needed . So , not based on login , RequestFilters , etc . Please focus on this example . While adding security to one RestEasy 'post ' method , I keep on getting 401 exceptions . How ...
Handling a basic/base64 security 401 exception in RestEasy and Tomcat
Java : I added this recursive BubbleSort algorithm to my game which runs on lwjgl . I 'm trying to sort an ArrayList of `` Cloud '' objects by a float which is the speed of this cloud.For some reason sometimes I get a `` java.lang.StackOverflowError '' at the line I invoke the method in itself.Here 's the code : And he...
BubbleSort StackOverflowError
Java : I have a static function with the following signature for a generic type Twhich should return a list of map keys with some property.Now I want to pass a generic HashMap of type Sin calling the static function within a generic class , which has the map as a member variable.I have listed a minimal code example bel...
Inferring a generic type from a generic type in Java ( compile time error )
Java : What is the reason of the exception message complains about duplicate key but shows the value instead ? Instead of show `` John '' as the duplicated key , it show `` 40 '' <code> List < Employee > employees = new ArrayList < > ( ) ; employees.add ( new Employee ( `` John '' , 40 ) ) ; employees.add ( new Employe...
Duplicate Key - misleading exception information ?
Java : Apologies that is probably the worst Title I 've used but I ca n't quite think how to word it.I 'm calling a method table.getColData ( COL_1 ) which returns a genericI am calling it twice and getting two lists of strings . I want to concatenate these and have ended up with this - which works nicely I think . I c...
casting & generics to enable list concatenation in Java 8
Java : I am trying to develop an ObjectPool , which can be used with any Object without changing the source of neither the Pool nor the Object - but I can´t find any way to write the get ( ) -function ( `` Maincode '' getting some Object from Pool ) as there is a Type-Mismatch ( Can not convert from Object to TestObjec...
Generic ObjectPool - how to return a generic class ?
Java : I was going through the Martin Odersky 's book Programming in Scala with it 's section on abstract modules , and his paper Scalable Component Abstractions : http : //lampwww.epfl.ch/~odersky/papers/ScalableComponent.pdfMy takeaway is that by making your modules abstract classes instead of objects ( or classic st...
Scala-style abstract modules in C # or other languages ?
Java : In my Java 8 app , I am scanning for whitespaces in text passed in . But \s in my Regular Expression does n't capture all whitespaces . The one whitespace that I 've found that it does n't capture so far in my testing is Non-breaking Space ( Unicode 00A0 ) . This was my regular expression that was running into t...
\s does n't actually capture all whitespace characters
Java : I come from an Actionscript3 background and this is my first time writing any Java in my life . Hashtables seem to be similar to Dictionaries in Flash , but I want to make sure I am using them correctly . I believe the Hashtable is typed to accept Strings as keys and Typefaces as objects . Is this correct ? Is t...
Is Hashtable appropriate for storing assets ?
Java : I 'm trying to understand Generic types in Java , and in theory it looks understandable , but when I need to apply it to real code I have problem . I want to declare abstract method which will return generic type . Let 's assume that I have some empty interface called Magicable and 2 class implements it : Magica...
Difference between using wildcards and declaring generic type in abstract method in Java
Java : I 'm trying to ingest a mp4 file and make it a timelapse . It works with the code attached below . However , the output file has frame rate of 16*originalFrameRate . Since I do n't intend to play it as a slow motion video I 'd prefer to drop those redundant frames to make the output file smaller.I was unable to ...
mp4parse timelapse frame rate
Java : I 'm trying to solve the multithreaded bank account problem* without using locks but using multiversion concurrency control . It 's working . It 's just a bit slow . How can I speed it up ? ( * ) I have 5 users , each starting with 200 - each randomly withdrawing 100 and depositing 100 into another bank account ...
Is it possible to solve the multithreaded bank account problem fast without locks ?
Java : I have very simple thing to do , i have list of persons like this : Result of this array should be : Adam ( true ) , John ( false ) So i need to return list of latest entries from users , in this case John first confirmed that he is attending , then he changed his mind and told that he is not attending so i 'm r...
Good way to filter list distincted by property and ordered by date
Java : given the interfaces ( which are very large and generated out of language definitions ) : Now compiling the interface VisitorA ( containing of about 2.000 overloaded methods ) needs about 10s.Compiling the interfaces VisitorB and VisitorC needs each about 1.5 min.But when we try to compile the interface VisitorD...
Java8 slow compiling for interfaces with thousands of default methods with the same name
Java : The following code for Integer uses object interning : It is not clear from API documentation whether this code for Boolean also uses interned object : Obviously , it may . But does it have to ? UPDATEI agree that source code can explain what actually happens ( BTW , thanks for the answers ) . To make the questi...
Is boolean interned in Java ?
Java : I have a method to rotate images but I always receive an OutMemoryError , but my images in the gallery iare taken from camera and size width is 5000~ from phone I resized photo to width 1280 and height 960my first method for show and resize image is And my method for rotate image is where is my error ? * -- -- -...
Android image resize error memory
Java : My IDE ( IntelliJ IDEA ) is telling me that I have the option to remove the braces on this if statement : To become : I understand how this makes sense , and it 's tempting to lose the indent , but my concern is that readability may suffer . The latter looks cleaner , but is the space saved worth the potential c...
Should multiple if statements like `` if ( condition ) if ( condition ) ... '' be avoided in Java ?
Java : I have a BigDecimal List such as : Then , I have another List of Integers : These integers refer to the index by which I want to reorder the first list . So , I would like to reorder the first list to be : I 'm using Java 8 . <code> [ 50.0,26.2,29.3 ] [ 2,1,0 ] [ 29.3,26.2,50.0 ]
How to Order one list by the index values stored in another list
Java : I am creating a custom class to set the max height of a NestedScrollView , based on the answer provided in this StackOverflow question : How to set the Maximum Height for a NestedScrollView in Android ? However , when I include the custom class ( MaxHeightNestedScrollView ) in my activity_main.xml code layout , ...
Android : Custom class for setting the max height of a NestedScrollView does not work ( there is no scrollbar )
Java : Due to a bug in the sigar library version I am using ( returns bogus values for swap ) , I tried using com.sun.management.OperatingSystemMXBean instead . This worked fine and gave me the desired results ( on Windows ) .However this breaks with java 9 . Is there another way to query swap file / partition informat...
Querying swap space in java 9
Java : & & is a short-circuit operator evaluated from left to right , so if the operand on the left side of & & operator is evaluated to false , evaluation should not continue . BUT I expected that the ++ should be evaluated before & & because it has higher precedence , and ( from the link ) : Operators with higher pre...
Java operator precendece confusion & & and ++
Java : I 'm a Java programmer . I have little knowledge on C # . But from the blogs I have read , Java supports only pass-by-value-of-reference whereas in C # the default is pass-by-value-of-reference but the programmer can use pass by reference if needed . I have penned down my understanding of how a swap function wor...
how does a swap method work in C # at a memory level ?
Java : I 'm looking for a java api that will correctly identify if a given ip address is private or local . This code seems to work for most ipv4/ipv6 addresses : Particularly , it identifies `` fec0 : : '' as a local/private type address but it does not identify , for example , `` fc00 : : '' or `` fd00 : : '' as loca...
Is there a java api that will identify the ipv6 address fd00 : : as local/private ?
Java : I am working on a bytecode instrumentation project . Currently when handling objects , the verifier throws an error most of the time . So I would like to get things clear concerning rules with objects ( I read the JVMS but could n't find the answer I was looking for ) : I am instrumenting the NEW instruction : o...
Bytecode and Objects
Java : While making up some arrays I noticed that prints out but only prints the stack location . I know char and String are both very different , but how come the JVM knows to output chars for the first and only a stack location for the second ? I am using IntelliJ and the command System.out.println ( javaArray ) ; <c...
Java Array Char And String Difference In Array
Java : It is said in manual , that if child does not implement Scrollable , then JScrollPane rely on preferredSize properties of it 's content.Apparently this is not true for me . I am increasing preferred height , but JScrollPane does not feel or react on it . <code> package tests ; import java.awt.BorderLayout ; impo...
How to implement JScrollPane child behavior ?
Java : I am trying to deserialize the following XML : My Jackson classes are : Bar is identical , just a different class name . ( In the real code they are different , this is just an example ) .And the root class isWhen I try to deserialize the XML , using this codeThe result is this ( note the lack of `` AAA '' ) : H...
Jackson XML deserialization skips field when using multiple useWrapping = false
Java : I need a function which can calculate the mathematical combination of ( n , k ) for a card game . My current attempt is to use a function based on usual Factorial method : It 's working very well but the matter is when I use some range of number ( n value max is 52 and k value max is 4 ) , it keeps me returning ...
Combinatory issue due to Factorial overflow
Java : I am working on a small java bytecode instrumentation tool . The general idea is to have all of a class methods renamed with a _CONGU suffix , creating then proxy methods with the original method names that will call their _CONGU counterparts . For instance , if a class C contains a int m ( ) { return 1 ; } meth...
Wrong number of arguments in stack when trying to instrument java bytecode
Java : I replied to a question earlier about thread safety which did not get a definite answer ( I think ) .So I have been trying to convince myself that the design is broken ( visibility ) by having thousands of threads read and write that object - but I have not been able to get anything unexpected . That is obviousl...
How can one break this ( non ? ) thread safe object ?
Java : Taken from the official Java tutorial by Oracle , see question 2 here ( boilerplate by me ) .The answer says that studentName is not eligible for garbage collection since the array students still references it . However , the final line prints `` Peter Smith '' , so to me it seems wrong that students [ 0 ] refer...
When setting an array element to a String object , does the element reference the object ?
Java : Using Java 8 , I get a compiler error for the following code : So essentially the compiler says `` I know you return boolean but you should n't , and if you do n't I 'm not sure what method to use '' instead of `` oh you 're returning boolean , you must mean the Predicate version of the method '' ? How does this...
Function and Predicate parameter ambiguous ?
Java : I am trying to design a data model which can hold a very large amount of data , does anyone with experience in large volumes of data have any feedback on this , ie : Based on what I have read , the only way to get transactional integrity on inserting a Transaction and updating balance is to make it one entity gr...
Transactions over very very large entity group
Java : I am a bit confused about this method reference syntax.counter ( ) expects a BiFunction however HighTemp : :lessThanTemp is a valid argument despite HighTemp.lessThanTemp ( ) only taking one argument.What exactly is happening in the line : if ( f.func ( vals [ i ] , v ) ) ? MCVE : <code> import java.util.functio...
Confusion about two-argument method reference
Java : This is somewhat of a follow up on Java8 retrieving lambda setter from class.I 'm trying to get a getter method for a given fieldThis is the underlying method : This does not compile , due to a type mismatch : This however does compile : And , to my surprise , this does work using the getter which was retrieved ...
Ensuring type safety on generic lambda expression
Java : I 'm reading the source of java.util.concurrent.ArrayBlockingQueue , and found some code I do n't understand : Notice this line : Why it does n't use this.lock directly , but assigns it to a local variable ? <code> private final ReentrantLock lock ; public boolean offer ( E e ) { if ( e == null ) throw new NullP...
Why it does n't use the instance field directly , but assigns it to a local variable ?
Java : When calling out the function testFunc ( ) , I am not using the syntax Apples.testFunc ( ) . Yet the code runs successfully . How so ? <code> class Apples { public static void main ( String args [ ] ) { testFunc ( ) ; } public static void testFunc ( ) { System.out.println ( `` Hello world ! `` ) ; } }
How a static method call works in Java ?
Java : I am currently evaluating implementations between Apache StopWatch and Guava 's Stopwatch and the split functionality in the former intrigued me , but I am struggling to understand what exactly it does , and what value it has.According to the documentation for StopWatch : https : //commons.apache.org/proper/comm...
What is the point of Apache Lang3 StopWatch.split ( ) ?
Java : I have a div that is a save button that has an awesome font symbol . After clicking the div , a new CSS class disabled is added where the opacity is reduced to visually signal the clicking of the button . After the save event the disabled CSS class is removed again and the button is fully visible again . If I tr...
How to listen to CSS change in Selenium ?
Java : I 'm having an issue with libgdx skin . When the app is paused or goes into the background and then reopens all my scene2d textures are just showing up black . I assume that the underlying textures need to be reloaded.I 'm creating my skin using the following codeMy question is if there any way that I can detect...
Libgdx reload scene2d skin after application hidden
Java : This is homework . I do not want the solution , just a small number of links or ideas.Simply speaking what I want to do is , Simple example : doThat ( ) is a method that is known to be time consuming , which results in my program blocking until results are back . And I want to use different methods of this Objec...
Remove blocking from a method
Java : I have a strange problem with variable initialization.There is following code : What ? ? ? Variable is initialized , what is wrong ? also when I change org.junit.Assert.assertFalse to my own local method error disappears.I am using jdk 1.7.0_51 if that matters . Class code is here <code> public void test ( ) { S...
Strange variable initialization error
Java : I have following code : If fist string equals `` email '' I want to remove first string from the Stream . For other strings from the stream I do n't need this check.How could I acheve it ? P.S.Sure I can transform it to the list , then use old school for loop but further I need stream again . <code> Stream < Str...
Remove first ( with zero index ) element from stream conditionally
Java : Is there any significant difference ( in performance or best practices ) between those two stream creation methods ? EDITThanks to Stack Community answers I can add some addons to question completeness for new readers : As many pointed out , .boxed ( ) IntStream method is defined as : What basically re-defines i...
Java 8 primitive stream to collection mapping methods
Java : when I open windows cmd and type jshell , it works , but when I 'm writing something . whenever I press the BackSpace key . for example if I want to delete a letter that is wrong . jshell crashes with bellow error , i 'm using windows 10 , and C : \Program Files\Java\jdk-11.0.1 is my only path in windows System ...
Jshell crashes when i press BackSpace button in windows cmd
Java : I have defined a function in Kotlin : I have defined a Java method with this signature : I attempt to compose them like so : When I compile I get this error : Error : ( ln , col ) java : unreported exception java.io.IOException ; must be caught or declared to be thrownHow do I define my function parameters to ac...
How do I declare a function parameter to accept functions that throw ?
Java : I have list of students.I want to return list of objects StudentResponse classes that has the course and the list of students for the course.So I can write which gives me a map Now I have to iterate through the map again to create a list of objects of StudentResponse class which has the Course and List : Is ther...
Flatten a map after Collectors.groupingBy in java
Java : I have a method which takes String argument . In some cases I want to pass int value to that method . For invoking that method I want to convert int into String . For that I am doing the following : One more option is : Both are correct . I do n't know which is appropriate ? Which gives better performance ? Most...
String conversions in Java
Java : As of now I have an object that looks similar to the below . Background : The problem is with this last toJSON function . I have two different functions ( listed here as TakesADataObjOrCollectionOfDataObjs and TakesAnObjectOrCollection ) which do different things based on if the object implements JSONable or not...
Java doing different things based on generic type
Java : I 'm seeing an extremely strange issue with Maven today : it 's trying to build classes that are not in my project , but coming from dependencies . mvn compile crashes with : There is no AppConstants.java in my project , and a search with grep -r AppConstants . gives no results . The class exists in another arti...
How is it possible that Maven builds classes that are not in my project ?