text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
Java : I have an annotation that can be added on METHOD and TYPE and is used in thousands of places in our project . Is it possible to make the annotation deprecated only on methods while keeping it non-deprecated on types ? I want other developers to be notified by IDE that it should not be used on methods any more , ... | How to make annotation deprecated only on one target |
Java : If I add @ Builder to a class . The builder method is created.I have a requirement where a particular field is mandatory . In this case , the name field is mandatory . Ideally , I would like to declare it like so.When googling i found many alternatives like overriding the builder implementation as below : And th... | Lombok 's builder with mandatory parameters |
Java : Please consider the following two functions : While composite ( first , second ) computes the composition of first and second , iterate ( function , n ) computes the nth iterate of function.While the restriction Y extends X suffices for any n > 0 , we 've got some problem with n == 0 . Mathematically , iterate s... | How to write a generic iteration of a function using Java 8 ? |
Java : i have a complex problem with Java 8.ProblemWith nested lambda compiler crash with a NullPointerException ! I know that lambdas must be stateless indeed in this case the codes that have state are Supplier implementations that however are anonymous classes and not lambdas.CodeStacktraceTestsI did several attempts... | Java 8 nested lambdas break compiler |
Java : I am new to Java and using a code given by someone . There , at the end of the code , they interrupt a thread if it has not finished . I am measuring the timing of the code.The problem is that the Java code first issues all the threads , and then at the end it interrupts . Is interrupting necessary ? Ca n't we w... | java : is interrupting thread absolutely necessary |
Java : I tend to use ( or even overuse ) double braces object intialization in GWT . For me it looks more readable and more declarative.Before today I was not aware that this syntax is not just instantiate object but also create AnonymousInnerClass for it . Now I am concerned how GWT deal with them . How this syntax af... | How harmful are double braces in GWT ? |
Java : This is probably a really stupid question , but I 'm having problems calling methods in java . For my computer science class I am instructed to write a single program with multiple methods . In one method I am to prompt the user to enter an integer , return that integer and store it in a variable . The next meth... | Calling Methods |
Java : I ran into this logic that someone had implemented at work today and it just feels wrong to be creating locks this way . Do you guys have a better solution for this ? The problem with not using synchronized block on myObj is that it can be null . Any other suggestions ? ? <code> public class myClass { private Ob... | Is this an acceptable way to create a lock in Java ? |
Java : First of all to prevent mark question as duplicate by guys who do n't like read to the end I have read Producer-Consumer Logging service with Unreliable way to shutdown question . But it is not fully answer the question and answer contradicts the book text.In book provided following code : Now we should to under... | Why can race condition in LogWriter cause the producer to block ? [ Concurrency in practice ] |
Java : In terms of memory used and impact on garbage collector , I would like to know if there is a difference between those two implementations : Also , if there is any functional difference , please tell me ! <code> protected List < T > _data = new ArrayList < T > ( ) ; // I want to reset this list using another one ... | Memory management : how to reset a list correctly |
Java : Some of our code is auto-generated ( by Apache Axis ) and it reports a ton of warnings . An example would be : Here , the warning would be HashMap is a raw type . References to generic type HashMap should be parameterized.Of course it makes no sense to actually address these warnings , as we have to trust Apache... | Java - Ignore warnings on directory/package level |
Java : In my scenario , a string is given to my function and I should extract only the numbers and get rid of everything else.Example inputs & their expected array output : In Qt/C++ I 'd just do it as follows : So with java I tried something similar but it did n't work as expected.So , what would be the best way to es... | Split string to get an array of digits only ( escaping white & empty spaces ) |
Java : Does anyone know how I can do a common `` OR '' like in a where clause , in firebase ? I need to do that in the query , because I am sending the query to an adapter . So , i mean , I can not add a listener and check one value and then another . I need to have the complete query pointing to that result in my quer... | OR clause in firebase java android |
Java : Introducing some of the goodness of collection operations to our codebase without adding a new external library dependency , we are adding these methods to our utility package.With the attendant interfacesSo the questions : Is Filters a good name for the class containing the extensions ? If not , a better ? Is M... | Naming Collection Extensions for clarity |
Java : I have a container running a Spring Boot microservice . I am using openjdk version `` 1.8.0_212 '' under OpenJDK Runtime Environment ( IcedTea 3.12.0 ) ( Alpine 8.212.04-r0 ) When I use -XX : +PrintFlagsFinal flag and print the JVM parameters I expected to see -XX : +UseParallelGC as trueBut to my surprise none ... | In Java 8 it is shown as none of the available 4 collectors ( GC ) are selected by default |
Java : I know when we are passing objects we are passing its reference as a value . But this value you get is using the hashcode ( ) method right ( according to my tests it 's the same ) ? Since hashcode ( ) is not the memory address and not guaranteed to get unique values all the time , can there be strange things hap... | what really happens when passing objects in java ? |
Java : I have a CustomDialogFragment like thisAnd from outside where I call the DialogFragment.I got the crash saying Any thoughts ? <code> public class CustomDialogFragment extends DialogFragment { private LinearLayout containerView ; public static CustomDialogFragment newInstance ( ) { CustomDialogFragment fragment =... | Custom Dialog Fragment Crashes when Setter Method is Called |
Java : I have a question on how to proceed with my code . My project is a tool which runs configurations one by one in the background . I would like to add a limit to it for the number of running configurations.For example , if I have 13 configurations I would like to run 5 configurations each time , so the order will ... | Running configurations with a limit |
Java : i have a question to Java Overload Methods . Suppose i have an overload methods foo : How can I implement to functions like of which one uses the overloaded string method , and one the overloaded object method ? The call of the foo-Method should use an String input . ( that means i do not want to work with a cas... | How to select which overloaded version of a method to call without using a cast ? |
Java : I 'm new in programming in Java and I do not understand what 's going on in my code.It tells me : My main.java is simple : this is addMine method : and Mine.java is : As You can see I wrote 2 println-s and both of them were false , so the object exists ! I do n't understand why it shows NullPointerException : ( ... | Java NullPointerException - Short Program |
Java : Possible Duplicate : Compiler complains about “ missing return statement ” even though it is impossible to reach condition where return statement would be missing The following method in Java compiles fine.The method has an explicit return type which is java.lang.String with no return statement though it compile... | Why is an error issued with an if statement in Java even though it is always true ? |
Java : I wanted to know if this is an implementation detail ... In Java , used local variables are captured for anonymous classes , and lambdas . For anonymous classes , the this is also captured in a non static context whether needed or not . It appears , however , any local variable referenced is captured even if not... | Unused referenced variables always captured in Java |
Java : So I have a piece of code where I 'm iterating over a list of data . Each one is a ReportData that contains a case with a Long caseId and one Ruling . Each Ruling has one or more Payment . I want to have a Map with the caseId as keys and sets of payments as values ( i.e . a Map < Long , Set < Payments > > ) .Cas... | Elegant way to flatMap Set of Sets inside groupingBy |
Java : I am using the library Apache-POI for my app . Specifically , POIshadow-all ( ver . 3.17 ) for reading a Word document.I am successfully extracting every paragraph as follows : what I actually need is extract every line , as follows : The code to extract every paragraph is this : The variable currentParagraph re... | Getting the lines of each paragraphs of a docx with Apache-POI |
Java : I 'm wondering to know which program variant are better runtime ? Both variants looks easy to implement . But what are better to use and in which cases ? String reverse : StringBuilder reverse : <code> public static String reverse ( String s ) { String rev = `` '' ; for ( int i = s.length ( ) - 1 ; i > = 0 ; i -... | Which variants string reverse are better ? |
Java : I have two methods in a class ... When I make the following call ... obj.method ( `` string '' , `` string '' , obj ) the correct method is called , however , when I try to call obj.method ( `` string '' , `` string '' , obj [ ] ) the first incarnation of that method is called . Is there any annotation or `` hin... | Java method overload choice |
Java : I have a tasks list object which I am iterating and appending each task object into StringBuilder followed by new line as shown below . Now I will keep appending task object in same string builder until it reaches a size limit of 60000 bytes . Once it reaches the limit , I will populate this string as a value in... | Populate string value in a map only if matches the threshold bytes |
Java : I have a code something like this and I want to make it scoped . But I found that this is not working and it seems only possible through in a module . I was n't able to find a proper question for this and is it possible to scope a constructor injection ? Does not workScope works ! ! <code> @ AppScope @ Injectpub... | Is it possible to scope constructor injection in dagger 2 ? |
Java : First , some environment : this is Oracle 's 1.6.0_45 JDK , and IDEA 13.1.I have stumbled upon a most bizarre compiler error : Funnel and PrimitiveSink are from Guava ; as to FieldNode , it is from ASM 5.0.1 ( org.objectweb.asm.tree.FieldNode ) .Note that I use IDEA ( 13.1 if that matters at all ) . Now , at fir... | Bug in compiler or am I doing something wrong ? |
Java : I'am currently working in a java project which I have a list of strings and I want them to have a specific format using streams .For exampleInput : [ nom , contains , b , and , prenom , contains , y , and , age , > = , 1 , and , age , < = , 100 ] Ouput : I wrote a very basic code without using streams : SearchCr... | forming a specific list with Java 8 streams |
Java : I 'm trying to do some pre-shutdown cleanup when a SIGINT is sent to my Java application , using the sun.misc.Signal and sun.misc.SignalHandler classes.It appears when I register my handler the default behavior no longer occurs . But there is a SignalHandler.SIG_DFL field containing `` The default signal handler... | Should I trigger the default signal handler when I define my own handler ? |
Java : Hi all I was browsing through some of the Java source code when I came across this ( java.lang.Character ) : I was wondering why did the writer added 1 to the higher limit and doing a lesser-than compare , instead of simply doing a lesser-than-or-equal compare ? I can understand if it helps readability , but in ... | char_x < ( char_y + 1 ) == char_x < = char_y ? |
Java : Not sure if I am wording this correctly . Please let me know if you require more information.We have a requirement where we need to determine the type of variable based on a system environment variable.So , say we have a the following classThe DUMMY_TYPE is determined based on a system variable . So when Java co... | Primitive variable type in compile time |
Java : I have been digging into spring security yaml a little bit yesterday to make it work with Okta SAML . Logging in works , but the response XML contains user attributes that apparently can not be extracted automatically into an attribute map . The response contains a fields like thisOnce an authentication is succe... | Spring Security SAML : Extract Attributes from a saml2p : Response as user attributes |
Java : I 'm struggling with this aspect of Generics in Java . Hopefully someone can help me see the ways.I have a class that holds a List of objects . This code works , but I want to get rid of the cast . How can I make this more generic ? <code> public class Executor { List < BaseRequest < BaseObj > > mRequests = new ... | Java Generics and unchecked cast |
Java : Keeping stacktrace out of it , lets say that the idea of 'error ' is a problem that you did n't want to occur , but did.If I were to use a boolean system to check if the action successfully completed , it would look something like this : If I were to use Exceptions , it would look like this : The only thing that... | Recommended way to handle problems/errors in algorithms |
Java : Let 's say I have a Shelf class and each Shelf has multiple Books.Now , let 's say from some method I have a List of Shelfs , each containing some books . How do I use stream to collect all the books to this list ? I 'm thinking something likebut it does n't seem to work , throwing a compilation error . <code> p... | Agregate nested list with Stream api |
Java : After running a recursive function to obtain an employee/manager family tree - a further requirement has come up to reserve an overall manager structure.So I would imagine the input array to look something like thisand the output array would need to look like thisThe hierachy needs to be sorted in this manner to... | Hierarchy Data shift |
Java : How do I enable `` -- enable-preview '' for tests in Kotlin-based Gradle script ? I tried literally everything I could find online with https : //stackoverflow.com/a/61849770/226895 being the closest to correct answer.I still get following error on : test taskby script isWhat am I missing ? <code> org.gradle.api... | How do I enable `` -- enable-preview '' for tests ? |
Java : Let 's say I have this hierarchy : This works fine , I can do : but I have to do a manual typecast.Is there a way to use java Generics in order to have the clone ( ) method return the actual type of the subclass ? Thank you ! <code> public abstract class AbstractEntity implements Cloneable { ... public AbstractE... | Using generics to implement a common method in an abstract class |
Java : What is the Java equivalent of these traits in Scala ? I translate the Strategy trait to : I try translating trait Visitor to : As you can see , I do n't know how to understand/translate type R in the Visitor trait . What is a similar Java equivalent ? <code> trait Visitor { type X type S < : Strategy type R [ v... | What is the Java equivalent of this Scala code ? |
Java : I 've tried to use buildpack in a maven project with Spring Boot 2.3.0 running : Image was created just fine , but I see the following info for it : Why does it say the image ( along with the builder ) was created 40 years ago ? <code> mvn spring-boot : build-image REPOSITORY TAG IMAGE ID CREATED SIZEgcr.io/pake... | Spring Boot 2.3.0 buildpack builds image with creation date 40 years ago |
Java : as per my understanding , 1st call to intern method should have created a 'string intern pool ' with a single string `` hello '' . second call to intern method would have done nothing ( as `` hello '' string is already present in pool ) . Now , when i say s1 == s2 i am expecting JVM to compare `` hello '' string... | Why intern method does not return equal String in java |
Java : I understand that == operator checks for equal references ( addresses ) but I am not getting how the compiler is throwing below error when comparing Thread and String object.java : incomparable types : java.lang.Thread and java.lang.StringHere is my code : Why is it allowing comparison between Thread and Object ... | Understanding == operator for Object Comparison in Java |
Java : I have one program in java..i am confused about the output.here output is 0 0 0 0 0But if i write , then output is 1 2 3 4 5Why it is coming like this ? ? ? <code> public static void main ( String args [ ] ) { int n=0 ; for ( int m=0 ; m < 5 ; m++ ) { n=n++ ; System.out.println ( n ) ; } } public static void mai... | Difference in the output in Java |
Java : I made a java.net.HttpURLConnection and it hang on the line connection.connect ( ) even though I ’ ve set a connect timeout . “ b4 connect ” gets logged and “ after connect ” never gets logged . I ’ ve tested on API 21 and above and things work , but I get this issue with my test on API 16-19 . Here is my code b... | HTTPS request hangs only on Android APIs below 20 even with a connect timeout set |
Java : This answer shows Java 's visibility modifiers and their meaning : My question is , why does allowing visibility to all subclasses imply that you must give visibility to all other classes in your package ? In other words , why did the Java creators make it like this , as opposed to : <code> Modifier | Class | Pa... | Why is package visibility given priority over subclass visibility ? |
Java : I 'm trying to figure out how to map data coming in on a request to a Hibernate object , and the issue is that the data coming in could be on the object or the child objects , and the field data is not necessarily known - the forms are user configured to contain and collect the desired data.Roughly , the objects... | Hibernate data mapping into child objects |
Java : Why does this code print 97 ? I have not previously assigned 97 to ' a ' anywhere else in my code . <code> public static void permutations ( int n ) { System.out.print ( ' a ' + 0 ) ; } | Do chars have intrinsic int values in Java ? |
Java : I 'm running this code with a Twitter handle I 'm pretty sure does n't exist in order to test error handling . The breakpoints on the Callback are never hit , neither for success nor failure.Any pointers on why this is ? Just as a note , this code works fine with a valid Twitter handle , but does n't call the Ca... | Twitter Android SDK not executing Callback |
Java : Consider the following interface : Which is implemented by the following class : Although meth ( ) is a method that throws an exception , the caller of the method meth ( ) is not having to handle or declare the exception and yet the program runs successfully . Why is this the case ? Does it not violate the rule ... | Why does the caller of the method that throws an exception not have to handle the exception in this situation ? |
Java : When using JColorChooser , entered CMYK values translate to a specific RGB color . When that color is entered manually on the RGB side , the CMYK valuesare not the same as before.The following program can be used to demonstrate the behavior I am encountering.In both panels , select CMYK and type in any valid num... | Anomalous behavior ( or possible bug ) in JColorChooser |
Java : Doing Java REST service performance test I see a pattern that was unexpected : a method that creates and returns always the same value object in each invocation runs faster than another version that just returns the value object stored in a class or object field.Code : Byte code : Inline ( faster ) : getstatic ,... | What JVM optimization is causing these performance results ? |
Java : So ... basically I have a docx file . And I have to do some formatting changes in few paragraphs and then save in a new file . What I am doing is essentially following.For most part everything is working fine . The output docx is opening allright in LibreOffice on my Ubuntu.But , when I transfer this output docx... | Infinite bogus pages in outpout docx using Apache Poi |
Java : This is an assignment question I received from school . The question says , write a method called capitalizer which will take the string `` ownage '' and then displays ( does n't have to return ) all the possible capitalization of it , such as `` OwNaGE '' or `` OWnAGE '' . It does n't have to work for every str... | Basic recursion |
Java : I have a Long string that I have to parse for different keywords . For example , I have the String : And my keywords areI have tried a lot of combination of regex but i am not able to recover all the strings . the code i have tried : <code> `` ==References== This is a reference ==Further reading== * { { cite boo... | Pattern Matching for java using regex |
Java : I 'm trying to create a very simple grammar to learn to use ANTLR but I get the following message : `` The following alternatives can never be reached : 2 '' This is my grammar attempt : I 'm using ANTLRWorks plugin for IDEA : <code> grammar Robot ; file : command+ ; command : ( delay|type|move|click|rclick ) ; ... | The following alternatives can never be reached : 2 |
Java : I am working on a small helper that is supposed to invoke arbitrary code ( passed in as lambda ) . The helper should catch certain exceptions , and throw them inside some wrapper . My `` own '' exceptions should not be wrapped but just re-thrown . I came up with this code : The above gives a compile error : Unre... | Why ca n't I have a catch for a checked exception for a call that throws a generic ? |
Java : I am trying to run a spring batch on application deployed on websphere . When I run the batch using eclipse all runs fine but when I run the same batch in deployed application on websphere it gives errorI checked source code of paranamer BytecodeReadingParanamer class and it saysI believe it means that the java ... | Paranamer error due to missing debug information in compiled class files |
Java : I have the following codeOP : Why am i getting `` false '' when i check s==s3 ? .. <code> public static void main ( String ... args ) { String s = `` abc '' ; System.out.println ( s.hashCode ( ) ) ; String s1 = `` abc `` ; System.out.println ( s1.hashCode ( ) ) ; String s2 = s.trim ( ) ; System.out.println ( s2.... | Why does `` == '' sometimes work with String.trim ? |
Java : Why Integer ii = ' a ' invalid , but int i = ' a ' valid ? Why Short ss = ' a ' valid , but Integer ii = ' a ' invalid ? another set question : Why b = L ; invalid , while b = s ; valid ? Please , do n't say it is all because JLS said so . I want to know why JLS has these inconsistent and non-intuitive rules . W... | java weird assignment rules |
Java : ** SOLVED **I 'm fairly new to Java and so far I love it ! So I 'm just asking if someone has a idea that could help me out . So here 's what I would like to do . What I 'm working on right now is a application that can interact with my local website ( change titles , content , etc ) . So what I like to do is sh... | Java concept idea |
Java : I am studying the workings of Inner Class and inside its bytecode , I was tracing the stack and could n't understand why is the getClass ( ) called ? I found a similar question for Lambda function but could n't understand it.I did try to understand that is required for no null check , after JDK 8 it 's been repl... | Why is getClass ( ) called when we create an object for Inner class ? |
Java : I am trying to sort the following stringsI currently have these values in an array of strings . I am trying to have an output where if there is no `` - '' then those values go to the end of my array in a sorted order . I am trying to have an output as follows : I have tried Arrays.sort ( arrays ) but I am not su... | How to sort strings such that values with extra information appear first ? |
Java : I 'm studing for the Java Certification 1Z0-803 and I hava a doubt about garbage collection : x is referencing the object X created at the position 1.This class X has a instance variable of the type List . If I referenced the instance variable list on x of the type X in a local variable list and then set x to nu... | Is an Object eligible for GC even if its instance variable is references to another variable ? |
Java : In C , the printf function has a great wildcard feature , where you can use an asterisk where you would normally place an int that specifies minimum column width . So you can goup in the preprocessor directives , and then later you can putto print myString in a 20 character column.This asterisk trick does n't se... | Losing magic numbers in Java printf format specifiers to generate columns |
Java : I have a to rewrite a part of an existing C # /.NET program using Java . I 'm not that fluent in Java and am missing something handling regular expressions and just wanted to know if I 'm missing something or if Java just does n't provide such feature.I have data likeThe Regex pattern I 'm using looks like : In ... | Regex Captures in Java like in C # |
Java : I am trying to use Apache Sling logging in an Equinox project . It is working fine , but I ca n't make Sling to use my config file . I am using a standard logback configuration xml , which should work according to the Sling documentation . But no matter where I put the configuration file Sling just does n't use ... | Sling logging configuration in Equinox |
Java : I 'm encountering this bizarre problem : the same code produces different results in Native Java than in Android . Given the following Inputstream ( read from a file ) Native Java prints out as expected . But in Android I got : Why does it behave differently in Android Java ? In Android , somehow the character '... | Unexpected StreamTokenizer behavior in Android |
Java : The overloaded functions compute1 ( ) , compute2 ( ) , and compute5 ( ) cause compilation errors if you try to use them below : After reading the JLS section 15.12 , I think I understand ... in phase 2 ( boxing/unboxing allowed , no varargs ) of matching overloaded methods , when determining the `` most specific... | Java : compile-time resolution and `` most specific method '' |
Java : We 've been using maven dependencies to specify the libraries so far , i.e . : However , we are now running the exact same .war file on different machines , and would like to keep the same One-war-file-to-rule-them-all , but do n't want to hit issues by using an older driver on a postgres 9.1 installation ( espe... | Can one .war file be built with both 8.4 and 9.0 postgres ( hibernate ) libraries ? |
Java : I wrote this line of code in eclipse mars for messing purposes : And I got the following compiler error message : Can not invoke toString ( ) on the primitive type nullWhich is very strange since null is not a primitive type nor an object reference as explained here : Is null an Object ? So , just to be sure , I... | Why does eclipse say that null is a primitive type ? |
Java : I am currently trying to wrap my head around bitwise and bit shift operators in Java . Although they make sense to me in simplified toy examples ( basically positive integers ) , my understanding falls apart as soon as negatives are involved , and in some other cases . I tried searching all over the Internet wit... | How , exactly , do bitwise operators work in Java ? |
Java : As I tried to see if I could answer this question earlier today . I realized that I do n't fully understand the Event Dispatch Thread ( EDT ) . Googling both confirmed and helped with that and clarified why I do n't . ( This might also be relevant to understanding . ) The code sets up a GUI and later ( as in the... | How does ignoring the event dispatch thread allow this program to work ? |
Java : I 've got an internal storage layer in my application , which handles Foo objects . During Get operations , the data layer has significant benefits to clustering gets , but I only actually do multiple gets about 10 % of the time . Here are various approaches I 've considered : Approach A : Approach B : Approach ... | What 's the Ideal Way to Define Singular vs Plural Gets in a Storage API ? |
Java : I 'm reading OCP Java SE7 , certification guide from Mala Gupta . On page 297 , the following code snippetis compiling with java 8 but with java 7 the compiler complains : My question is : What change in type inference algorithm causes this behavior ? <code> import java.util.HashMap ; import java.util.Map ; publ... | What change in type inference algorithm causes this behavior ? |
Java : I 'm exploring a Java grammar parser and I came across this strange piece of code that I would n't normally use in ordinary code . Taken from https : //code.google.com/p/javaparser/source/browse/branches/mavenized/JavaParser/src/main/java/japa/parser/ASTParser.java # 1998It has many functions that contains code ... | Uncommonly used Java syntax ( JavaParser ) ? |
Java : I have a set of entities and I need to group this entities in groups called specie . The set of all species defined calls Universe and an entity must belong to one and only one specie . For this I have a boolean intransitive function called f that returns if two entities , passed by parameters , are compatible .... | Algorithm to find the optimal group of compatible elements |
Java : I 'm having trouble fixing this problem ; it 's been plaguing me since yesterday ( sorry , I posted this earlier then deleted it because I thought I solved it but it turned out to be another bug I fixed ) . I 'm trying to simply take a list of items and a range and to find combinations that would allow all items... | Trouble designing recursion with limited results |
Java : Is it good practice to start a thread within a thread ? I have searched around but have not found much information.I have a TimerTask which gets a list of users every day at a certain time . I then want to get some data about the user , but this requires user input . Because it requires user input , I do n't wan... | Create Thread within a thread - good practice ? |
Java : How would I get this data structure using Java 8 API ? This is my object structure : I 'm trying to aggregate it tofrom <code> class A { B b ; public A ( B b ) { this.b = b ; } } class B { List < A > as ; private int i ; public B ( int i ) { this.i = i ; } } Map < A , List < B > > bs ; List < A > as = new ArrayL... | Java 8 Streams groupingBy collector |
Java : I 'm trying to add log4j to a legacy software using eclipse search/replace . The idea is to find all class declarations and replace them by , the declaration itself plus the definition of the logger in the next line.search replace : How can I prepend the matched pattern ( the class definition ) to the replace st... | How to repeat text matched by a regex ? |
Java : I am new to Android and I started making my first application following tutorials and such . However , when I click the run button it gives me following error on the logcat from which I count not identify where the error is . Hence , here is my code in hope of some advice . Thanks in advance.LogCat after fixing ... | My first app is n't working and it crashes : UnsupportedOperationException |
Java : Declaration of a character : When I do this i am getting the error 'empty character literal'.Declaration of a String : I see no error in doing that to a String.The question is , why does n't a similar error show up for the declaration of a String , or why declaration of empty character generating such error wher... | Declaration of characters and Strings |
Java : Java has special markers on methods called synthetic and bridge . JLS 13.1.7 , `` Any constructs introduced by a Java compiler that do not have a corresponding construct in the source code must be marked as synthetic ... '' So synthetic methods are anything generated by the compiler and not represented in the so... | Can a synthetic or bridge method be used to smooth an int - > double API change ? |
Java : I am currently taking a Data Structures class and , as you may expect , one of the things we have to do is write some of the common sorts . In writing my insertion sort algorithm , I noticed in ran significantly faster than that of my instructor 's ( for 400000 data points it took my algorithm about 30 seconds a... | Very Strange Efficiency Quirks while Sorting |
Java : I have three modules : module-a , module-b , module-c. Module-a and module-b are in boot layer . Layer for module-c I create myself.Module-a has one interface com.mod-a.Service and in its module-info I have : Module-c implements com.mod-a.Service and in its module-info I have : Module-b creates new layer with mo... | How to call a service from module in a new created layer in Java 9 ? |
Java : Ok , now here 's the issue . The current code above gets an x , y , z and r ( range ) . It 's job is to reference through the `` cube '' until meets a certain condition I 've set . The problem lies in the fact that it starts on the outside of the cube and progresses from 1 corner to another corner basically.I 'm... | Creating a check that needs to loop outwards from the middle of 3 variables ( x y z ) |
Java : Consider this method ( just for illustration ) : That , of course , is not Java , but it could be in your favourite alternative language that supports collection literals , such as Groovy or Kotlin . The expression is succinct , and , just like string literals , the compiler is allowed to put the collection lite... | Java 9 collections ' convenience factory methods as an alternative to collection literals |
Java : Can someone explain why the second loop is 20x times slower than the first ( 19 ms vs 232 ms ) ? That is how I 'm timing it : <code> int steps = 256 * 1024 * 1024 ; int [ ] a = new int [ 2 ] ; // Loop 1for ( int i=0 ; i < steps ; i++ ) { a [ 0 ] ++ ; a [ 0 ] ++ ; } // Loop 2for ( int i=0 ; i < steps ; i++ ) { a ... | How does array access affect the performance ? |
Java : I wanted to test the '== ' operator on Longs and this is what I 've found : the following code : outputs : The only explanation I could come up with was that the JVM stores all long values inside [ -128 , 127 ] in the Perm space , and gives their address to Longs and to everything outside the above range it crea... | What 's the cause of this strange Java behavior ? |
Java : When I was using adt16 in my eclipse everything was ok , but when I use adt 20 then in the package explorer it doesnt show the project names , the projects are being separated by their packages and launcher java class names likeso this is irritating , how can I get rid of it ? <code> Version : Indigo Service Rel... | Project name doesnt show in my eclipse |
Java : I have made a very simple Scala program which just prints Hello World : To understand how Scala converts to Java bytecode I decompiled the resulting jar file where there are two files : HelloWorldActivity.class and HelloWorldActivity $ .class.The first one contains this code : while the second one contains : wha... | What does `` new ( ) '' do inside `` static '' and how does `` static '' alone not throw a compile/run error ? |
Java : So , as I understand , one should always program to an interface , as in : So , later in my program I have : Can I follow a better pattern here or somehow do something to avoid the cast ? Casting seems very ugly in this scenario.Thanks . <code> List < Integer > list = new LinkedList < Integer > ( ) ; public List... | Programming to an interface - avoiding the later cast |
Java : I have a variation of the following code : And as you can see , my queue is not compatible with the ThreadPoolExecutor constructor . Is there any way to work around this than cast my queue to ( BlockingQueue < Runnable > ) ? I obviously ca n't patch Java Standard Library . <code> package com.test.package ; impor... | How can I make my generics code compatible with this method signature ? |
Java : I made this recursive method that calculates the longest path in a binary tree . the path its store in an arralist and then returned . however , i had to declare the array list variable global . is it possible to make this method but his the array list variable being local.The reason i had to make it global is b... | how to make a variable local |
Java : This might be pretty basic , but was very curious to know . Here 's the code snippet and the outputand the outputI am interested to know what is GC collecting here since no objects are created . What 's the memory thats being freed up ? ( and that too 52kb ) @ JSauer - It gives Exactly the same results even if r... | What is GC collecting here ? |
Java : Some Android phones do n't do anything when the the code below is ran . It 's supposed to open the `` About device '' page in Settings.For example , I know for a fact that it has no effect on the Huawei Y9 Prime 2019 running Android 10.What 's the best way to safeguard against this issue when it occurs ? ( In my... | Some Android phones not opening “ About device ” page in Settings ? |
Java : Elaborating on this : I map a servlet or filter to `` /* '' Now , if I access a url like : Then this will be directed to the servlet ( which is okay ) But if i access a url like : This will be directed also to the servlet , I dont want this behavior , what I want is for index.jsp to be processed as jsp.How can t... | Is it possible to map a servlet to /* without overriding JSP processing |
Java : I have been searching for clear answers desperately and I think I kinda get it but at the same time I do n't quite get the broad concept of that keyword , static.Here 's the scenario I 've made : Why ca n't you declare a variable as static inside the static method ( or any method ) ? What does `` scope '' mean ?... | the concept of STATIC variables , and methods in Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.