text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
Java : I wrote this class : javac ListArg.java // compiled classI compiled above class and run like : java ListArg *But ListArg is displaying current directory contents on console and not `` * '' . <code> public class ListArg { public static void main ( String args [ ] ) { for ( int i=0 ; i < args.length ; i++ ) { Syst... | Strange Behavior of Java Argument * |
Java : I was learning to write some lambda representation as FunctionalInterface.So , to add two integers I used : Gives me the output 70 . But if I write it as this I get an error saying Wrong number of type arguments : 3 ; required : 1Is n't BinaryOperator a child of BinaryFunction ? How do I improve it ? <code> BiFu... | Which FunctionalInterface should I use ? |
Java : I 've tried searching for it , but I do n't really now how to formulate the question correctly ... I have an if-statement with many logical operators . How do I do this easier ? I 'm thinking in pseudo-code I want something like this : As you understand , I 'm a beginner and I have problems formulating what I ne... | I need help making an if statement with many logical operators easier |
Java : I decided to an solid rpg-like game structure with Java to practice design patterns.Basically there are different types of characters in my game , which are all considered to be `` game objects '' , having some common features : Status here is an enumeration : I would like to make my code flexible , easy-to-modi... | Design pattern to customize possible statuses of a Character in a game |
Java : I have added this gradle task and then I get this error : what is wrong with my syntax ? I saw this tutorial : <code> FAILURE : Build failed with an exception . * Where : Build file '/Users/eladb/WorkspaceQa/java/UsersServer/build.gradle ' line : 98* What went wrong : A problem occurred evaluating root project '... | org.gradle.api.tasks.testing.junit.JUnitOptions.includeGroups ( ) is applicable for argument types : ( java.lang.String ) values : [ NoDbTests ] |
Java : I am designing an application that has two widgets : -A list that contains arbitrary objects-A table that displays specific properties of the currently selected objectThe goal is to be able to pick an object from the list , look at the properties , and modify them as necessary . The list can hold objects of vari... | Displaying various objects ' instance variables in a JTable and modifying them |
Java : I have the pattern `` ddMMyy '' in my code I have specified it using the appendValue methods : However this produces `` 0099 '' for year : 0099-01-10If I change that to using the appendPattern like that : I have the correct result for year `` 2099 '' with century in it . 2099-01-10The code seems equivalent for m... | Java8 appendPattern vs pattern defined by appendValue methods produces different result |
Java : I have a WebDriver based Java testsuite , which I try to execute with Jenkins.Project is imported and build was successful.During execution of test I get following : Running TestRunner Configuring TestNG with : org.apache.maven.surefire.testng.conf.TestNG652Configurator @ 2437c6dc org.openqa.selenium.firefox.Not... | Firefox WebDriver : Failed to connect to binary |
Java : Given a function Function < T , T > f and a Stream < T > ts what is a good ( nice readability , good performance ) way of creating a new Stream < T > which first contains the original elements and then the elements converted by f.One might think this would work : But this does n't work and results in an exceptio... | Adding an element to the end of a stream for each element already in the stream |
Java : I found this on github occasionally.Could this happen in common use ? <code> md5 ( text ) .equals ( text ) | Could md5 algrithom generate the same string with the original string ? |
Java : Some byte arrays using new String ( byte [ ] , '' UTF-8 '' ) return different results in jdk 1.7 and 1.8bytes2 use new String ( byte [ ] , '' UTF-8 '' ) , the result ( str2 ) is not the same in jdk7 and jdk8 , but byte1 is same . What is special about bytes2 ? Test the `` ISO-8859-1 '' code , the result of bytes... | new String ( byte [ ] ) results differ in JDK 7 and 8 |
Java : I 'm working on code that calculates entries in the StackFrameMap ( SFM ) . The goal is to be able to generate ( SFM ) entries that make the Java 7 bytecode verifier happy . Following a TDD methodology , I started by creating bogus SMF entries for the verifier to complain about ; I would the replace these with m... | Why does n't the Java 7 byteode verifier choke on this ? |
Java : I know there are many topics and resources about this , but I 'm wondering about a very specific question ( and it might take a very long time to check all sources for a definite answer ) . I know that JVM/Dalvik guarantees that by the time you access a static field of a class ( except for final static primitive... | Is static init guaranteed NOT to run if class is not accessed ? |
Java : This creates literal `` abc '' in string pool . No new literal is created . b is pointed to the existing `` abc '' .Now the object is created in heap and c is pointed to the heap . The literal is also created in the string pool.But , what happens if the pool already has the literal `` abc '' ? Will there be dupl... | How strings are handled in java |
Java : I have a command line program to validate an XML against an XSD file . One of the command line options for this program is the namespace to use , which is stored in String namespace . I get a different validation result depending on whether I pass the parsed option as namespace or pass the call to namespace.inte... | Why do I get different results with String.intern ( ) vs. passing String object in Java ? |
Java : I 've a question on how to apply Java 8 group by . The group by solution in books and other questions / forums illustrates applying on a object property , like a getter method , but my case is bit different . I 've a DB query result set which is a List inside List . The inner list is sometimes a List < Long > or... | How to use Group by on a result set response |
Java : I 've been trying to switch from the Oracle OCI driver to the thin driver , I got the thin driver to pickup my tnsnames.ora by adding -Doracle.net.tns_admin=/path to the command line.However , our tnsnames.ora contains lines where multiple services are defined at once . They look like this : The OCI driver seems... | Declaring multiple identical service in tnsnames.ora supported by oracle thin driver |
Java : I 'm new to programming , I 'm sorry if this is a silly mistake , but I keep getting this error `` CompanyAddress.java:11 : error : can not find symbol System.out.println ( testObject.getName ( CompanyName ) ) ; '' I do n't know what I 'm doing wrong.The main.my test.java <code> import java.util.Scanner ; public... | I ca n't get this to work , methods & instance variables |
Java : I have a class representing DB-Entries with a unique Id attribute.Is is OK to implement the equals ( ) and hashcode ( ) methods only based on this attribute <code> @ Override public int hashCode ( ) { return id ; } @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == nul... | Is this naive equals , hashcode OK ? |
Java : Probably I am missing something and maybe my assumptions were wrong , but I thought that when I declare parametrized method with type T then no matter how much variables there are with that type it is still the same type . But I see that this compiles and it oposses my view.So if my method is parametrized with o... | Method parametrized with one type accepts two types |
Java : I need to check if a returned list was created once or if it 's a copy of an object . Is it possible to find out it 's address ? How could getAddress ( list ) look like ? The problem is that hashCode ( ) which normally returns an address is overridden in AbstractList , so it would return a valid hash code instea... | How can I get an address of a List ? |
Java : While solving a challenge online , I observed the following behavior of java which I found a little weird . I started off by compiling a program along the following outline : Notice that in the above program , there are two errors : I have not handled exceptions which might be thrown by BufferedReader.I have not... | Unexpected order of errors in java compilation |
Java : I have a generic interface interface ListList < E > extends List < List < E > > . For some reasons , I ca n't cast ListList < ? super T > to List < List < ? super T > > . Is there any way of doing it and why it does n't work ? By this moment I 've already tried the following : Simple assignment , this way I 've ... | Why ListList < ? super E > is List < ? extends List < ? super E > > but not List < List < ? super E > > |
Java : I have built a User management service in which I 'm using MongoDb ( spring data ) . I have two models User and Role.Role model -and Role enumerator-In User there is a role attribute which I have @ Dbref to role collection . My problem is that I want to have a option of using PostgreSql and MongoDb in the same a... | Is it possible to use MongoDb and PostgreSql for same model in Spring boot ? |
Java : Why does the below snippet compile ? OtherInterface does not extends Concrete so I would have bet a kidney that this would n't compile . But it does.On the other hand , the next snippet does not compile , which is what I expect . <code> public class Test { public static interface SomeInterface { } public static ... | Apparent type violation , but compiles |
Java : I am trying to improve the performance of some code . It looks something like this : What I noticed is that many of the Patterns seem to be simple string literals with no regular expression constructs . So I want to simply store these in a separate list ( importantList ) and do an equality test instead of perfor... | How do I determine if a string is not a regular expression ? |
Java : Looking java 's hashmap implementation , not able to understand the reason behind some lines . In below code copied from here , in line 365-367 , I am not able to understand why have they done the assignment of e.key to k first and then compared == with key [ ( k = e.key ) == key ] . Why not directly do ( e.key ... | in java hashmap implementation key is first assigned to object and then compared |
Java : I have a Many-to-Many relationship between the class Foo and Bar . Because I want to have additional information on the helper table , I had to make a helper class FooBar as explained here : The best way to map a many-to-many association with extra columns when using JPA and HibernateI created a Foo , and create... | Hibernate Many-to-Many with join-class Cascading issue |
Java : As discussed in this question , the equals method of java.awt.geom.Area is defined as public boolean equals ( Area other ) instead of overriding the equals method from Object . That question covers the `` why '' , and I 'm interested in `` how can I force Java to use the most appropriate equals method '' .Consid... | Java reflection to call overloaded method Area.equals ( Area ) |
Java : If a class A makes public Object 's clone ( ) method : What will be the instanceof ( or getClass ( ) ) of an instance of A created using clone ( ) ? What about instances of class B extends A created using the clone ( ) method ? EDITClarification : I ask this because even before compiling , Eclipse java editor re... | What is instanceof of a cloned object ? |
Java : Why does this code totally destroy the output ? Sample output I get : Boo.Boo.Boo.Boo.Boo.Boo.Boo.Boo.Boo . <code> public class Main { public static void main ( String [ ] args ) { System.out.println ( ) ; rec ( ) ; } private static int rec ( ) { try { return rec ( ) ; } catch ( StackOverflowError e ) { System.o... | Odd Java StackOverflowError ? |
Java : I 've typed up a bunch of String [ ] arrays in an interface . I want IntelliJ-IDEA to order the elements alphabetically . I 'm not talking about ordering during run-time or compile-time . I want the actual java/text-file to be modified.How can I get IntelliJ-IDEA to sort String [ ] array elements alphabetically ... | How to order pre-written String [ ] array elements alphabetically pre-run-time in IntelliJ-IDEA ? |
Java : BackgroundI would like to understand why a snippet of code does not throw a NullPointerException.Source CodeConsider the following code : The deliver method is called repeatedly , whilst the following code runs in a separate thread : There is only a single agent instance.ProblemA NullPointerException is never th... | Why does this code not throw a NullPointerException ? |
Java : According to Android documentation , in above code , zero is slower . But I do n't understand why ? well I have n't learn that much deep but as I know length is a field not method . So when loop retrieves its value , how its different from retrieving from local variable ? and array length is always fixed once in... | Performance tips questions |
Java : I have the following Java class with multiple level of inheritance with certain type parameters . I want to use the type parameter T in class B . However , he following does n't compile : Although I can define the variable t in class C , but it is not a good coding practice . How can I define the following ( Thi... | Multiple Level of Inheritance |
Java : Following is the simplest example of static inner class in Java . Let 's look at it.Within the Outer class , there is a static class named Inner and a static object with the same name Inner of type Extra . The program displays Whilte on the console , a string in the Extra class through Outer.Inner.s in main ( ) ... | Static classes in Java -- something is being shadowed |
Java : There is a method in hamcrest library : In my code , I call this method with first being Matcher < Object > and second being Matcher < SomeException > .And now : When I compile it with Eclipse with 1.6 target , it makes < T > Matcher < SomeException > .When I compile it with javac 1.7 with 1.6 target , it makes ... | For method of type T , what should be its 'inferred ' type when it takes two < ? super T > arguments ? |
Java : The title may be misleading but as a non-native i could n't figure out a better one.Say i have two classes , Dog and Fox : And i create some instances as well call some methodsFor the 1 . Ouput I expected `` RingdingRingding '' because hybrid actually is a reference to an instance of the Dog , even if the refere... | Class type of reference and the actual class type , which decides which method to call ? |
Java : When redeclaring Integer ' a ' in line 33 , why does jshell show the reference variable as an instance of Integer ( refer to lines 38 & 39 ) ? After the redeclaration , line 34 shows that ' a ' is set to null . When ' a ' is declared in line 6 but not given a value , or reset to null in line 22 , ' a ' is not co... | In jshell-11 , why does a redeclared reference variable that resets to null still have a type ? |
Java : I try to use Mockito to mock the getDeclaredMethod ( ) of java.but the parameter of this method is un-certain . how to mock such method ? <code> public Method getDeclaredMethod ( String name , Class ... parameterTypes ) throws NoSuchMethodException , SecurityException { throw new RuntimeException ( `` Stub ! `` ... | Java Mockito- how to mock uncertain number of parameter method |
Java : I started learning Java and I could n't understand one of examples in `` Thinking in Java '' book.In this example author represent , as he state `` simple use of 'this ' keyword '' : And when above code is working as indeed , I cant understand what increment ( ) method is returning . It 's not variable i , it 's... | What is returning class when use `` return this '' ? |
Java : What is happening : :At the startdate=2014-12-17T21:37:00+00:00At the endneedbydate= Dec/18/201417 is changed to 18 ... . What wrong am i doing in conversionEDIT : <code> String date = jsonobject.getString ( `` needbydate '' ) ; DateFormat df = new SimpleDateFormat ( `` MMM/dd/yyyy '' ) ; DateFormat sdf = new Si... | Error in conversion of dates in java |
Java : I have a question about best design practices . I have been attempting to build more immutable components into my project because I read they were easier to maintain in the long run and wanted to test this . When you have a class with immutable data members , say Should the int still be declared as private and g... | Should an immutable class member have an accessor method or allowed to be public ? |
Java : I have following code : mQuestions is empty ArrayList , and I see that count equals 0 on Log always . Also I see 1/111 record on my Log always too . But my activity does n't do a finish method ! makeQuestion is method that need n't work with empty mQuestion ( it throw Exception ) . But If I make a comment for ma... | Why does n't this activiy finish ? |
Java : I have two similar pieces of Code : I would like to avoid code duplication and I thought this could be done by using a functional approach.I want to put the loop and the init/shutdown call in seperate functions and then chain their calls ( not the Java 8 Function interface , more pseudocode ) : Then I want to ch... | How can I chain functional calls in Java ? |
Java : I want to write a regular expression in java which will accept the String having alphabets , numbers , - and space any number of times any where.The string should only contain above mentioned and no other special characters . How to code the regular expression in java ? I tried the following , It works when I ru... | How to write and use regular expression in java |
Java : In my spring-boot 2.3 application , I have a simple data method using DatabaseClient : With spring-boot 2.4 ( and spring 5.3 and spring-data-r2dbc 1.2 ) , org.springframework.data.r2dbc.core.DatabaseClient from spring-data-r2dbc is deprecated in favor of org.springframework.r2dbc.core.DatabaseClient of spring-r2... | Spring R2DBC DatabaseClient.as ( … ) |
Java : This code causes a compile error with javac ( but , notably , not with Eclipse 4.2.2 ! ) : The error from javac is this : Changing the cast to ( Bar ) foo ( i.e . using the raw type ) allows the code to compile , as does changing the type of foo to simply Foo < ? extends Iterable < ? > > .EDIT : Hilariously , th... | Why is n't a conversion to `` GenericType < ? > '' allowed here ? |
Java : I need to obtain the underlying OS PID for a Process I start . The solution I 'm using now involves access to a private field through reflection using code like this : It works but there are several problems with this approach , one being that you need to do extra work on Windows because the Windows-specific Pro... | How to obtain pid from Process without illegal access warning with Java 9+ ? |
Java : First variant gives more flexibility , but is that all ? Are there any other reasons to prefer it ? What about performance ? <code> Collection list = new LinkedList ( ) ; // Good ? LinkedList list = new LinkedList ( ) ; // Bad ? | Is a Collection better than a LinkedList ? |
Java : I 'm trying to apply my knowledge of streams to some leetcode algorithm questions . Here is a general summary of the question : Given a string which contains only lowercase letters , remove duplicateletters so that every letter appears once and only once . You must makesure your result is the smallest in lexicog... | Java 8 Streams Remove Duplicate Letter |
Java : Are there any conventions as to whether a method called by another method should generally be above or below it ? E.g . say caller ( ) was refactored into two methods - where would be the more standard place out of aboveCaller ( ) or belowCaller ( ) ? Although this is in Java , it is a general programming questi... | Should a worker method generally be placed above or below the methods that call it ? |
Java : I am trying read the Oracle table information from my application . To get the table description , I execute this query on my application : Here is the code block that executes query : When I run the sql directly on the database I get this result : When I run my application , it returns the result like this : Th... | Prepared Statement does not retrieve the exact result of the sql |
Java : I have two factory-methods which produce `` consumers '' use different approaches lambda and method references : I found that in first case ( lambdaPrintStringConsumer ( ) ) , method return reference to the same objectbut in the second ( methodRefPrintStringConsumer ( ) ) , objects is differentdirect approach re... | Why Functional interface initialize different when use lambda in factory-method and method reference ( singleton / prototype ) ? |
Java : When I run the following code on Intellij with input 1000000000000 the process holds a moment every 8 million loops.Why is it like this ? Why does n't run in one smoothly flow until the end ? <code> import java.util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ... | for loop makes pause every 8 million iterations - why ? |
Java : I have a JSON value as follows in String format . Now if I try to map this as follows , it works and maps fine . But I want to map it to a custom Data class as follows . When I do this , the result of vo is null . Refer to following on how the Data class is structured . Please advice what I am doing wrong . Than... | Unable to map String to Object |
Java : I have a small implementation detail question that I fail to understand in ArrayList : :removeIf . I do n't think I can simply put it the way it is without some preconditions first.As such : the implementation is basically a bulk remove , unlike ArrayList : :remove . An example should make things a lot easier to... | removeIf implementation detail |
Java : I want to create a function which returns two counted values . The values are counted by iterating over a for-loop.For example , I have an array of persons ( male , female , adults , children ) and I only want to find the amount of boys ( child + male ) and the amount of women ( adult + female ) .In the last few... | Return 2 counted values from one function |
Java : I am using the below code for epoch to time conversion by using java.util.Date class in Java.Below are the outputs while running the same code on two different timezone server : On EDT server-On IST server -Why does this happen ? I am only passing milliseconds . This data is supposed to be treated as 21:15 on al... | Different time conversion by using java.util.Date in Java |
Java : I have 2 questions about Arrays in Java , hope you can spare your time to help me.Question 1 : But it returns false ? Question 2 : I run this code : and it returns -2 . BUT when I remove duplication : now it returns 2 , which is the right one . I do n't know how binary Search in Array deals with duplication whic... | Some questions about Arrays |
Java : I know that you can only have an array of a certain type ( e.g . String , int , Student , etc. ) . I was wondering if this held true in the case of inheritance - i.e . whether or not a Bicycle object that extends Vehicle could be placed in a Vehicle array along with something else , like a Bus object.Here 's my ... | Can you have an array of different kinds of objects ? |
Java : Consider the following two classes and interface : Why does the second call to mandatory invoke the overloaded method with Class2 , if getInterface1 and Interface1 have no relationship with Class2 ? I understand that Java 8 broke compatibility with Java 7 : And with Java 8 ( also tested with 11 and 13 ) : <code>... | Why does the compiler choose this generic method with a class type parameter when invoked with an unrelated interface type ? |
Java : I have an XML schema , where element Calling1 is defined like this : I have generated Jaxb bindings : I am using JAXB to unmarshal XML documents to Java representation . If my XML cantains element Calling1 , which value is not a correct dateTime , for exampleJAXB does not throw any error , but returns me an java... | JAXB does not throw an Error on wrong dateTime values |
Java : As you all know it is possible to fetch a method with Reflection and invoke it through the returned Method instance.My question is however ; once it is fetched by Reflection and I invoke the Method over and over again will the performance of the method be slower than the normal way of calling a method ? For exam... | Does the execution of a method fetched by Reflection take longer ? |
Java : Let us say I have the following classes : AnimalCatDogCowAnimal is the base class , cat , dog , and cow each subclass it.I now have a Set < Cat > , Set < Dog > and Set < Cow > each of these are used in the same way , so it makes sense to make a generic function to operate on them : This works great , I can freel... | Adding to a Generic Set passed into a method |
Java : I am bit surprised that the default ( native ) implementation of the hashCode ( ) method appears ~50x slower than a simple override of the method for the following benchmark.Consider a basic Book class that does not override hashCode ( ) : Consider , alternatively , an otherwise identical Book class , BookWithHa... | Java hashCode ( ) : Override faster that native implementation ? |
Java : I have this : I want to merge the boolean expressions into one . So I use this : However , I am worry if this is correct . Is this correct ? Could this be simplified/shorten ? With the help of the answer the shorten solution is : <code> // returns true if both are equal ( independent of scale ) and also checks a... | negation of boolean expressions with XOR |
Java : Lately , I 'm having a heated discussion regarding this issue . Lets say I created this method in Java : Whenever I see that in a pull request , I shout and try to explain why it is wrong . By doing that , I 'm misguiding the consumers of my method by the promise that they will get a Set . This means they can re... | A method declaring a mutable data structure as an output and returning an immutable one actually |
Java : I have a function : So , if I were to do something like : this is all good.However , in another function : Gives me an error , because base.getClass ( ) returns ? extends R.Now from what I understand , the function get ( Class < T > x ) returns T , so when called with ? extends R , which let 's say is CAP # 1 , ... | Why does a wildcard on a generic parameter require an explicit cast ? |
Java : I have a arrayList with values { a , b , a , c , d , b , a } I want to make a comparison of each element in the list and insert the pair of common indexes into a List of array or something using javaexample output : [ [ 0,2,6 ] , [ 1,4 ] ] explanation : a is at indexes 0,2,6 and b is at indexes 1,4So far I have ... | How to create a List of arrays using java |
Java : When I generate a stub ( using Eclipse Oxygen , top-down , Axis1 ) , the function are generated like these : Why is TokenRequest class kept intact , while BatchCommand and HttpHeaders are dismantled ? I tried adding more sub-elements under HttpHeaders and BatchCommand , but they just get split up as additional p... | Top-down Web Service Generation using AXIS1 is taking my complexType apart |
Java : I wrote a piece of code and wonder how I can write it more elegant , using streamshere it is : Here - some boolean is returned from a method . If specified date already exists in some task it returns false , otherwise true ( so the return type answers the question raised in method 's name : ) ) I was trying with... | How to write it using streams ? Java 8 |
Java : Every now and then I find myself with indexed loops , for which I want to permutate the order to some random order.I usually transition from something liketo This is neither efficient nor elegant . Is it possible to create a Stream ( ideally an IntStream ) in a certain range , but have it return its elements shu... | Random permutation of IntStream |
Java : I 'm working with Android Studio and I keep getting a problem I do n't know how to solve . I do n't know whether it 's a problem with Android Studio , with Java or a mistake a make.I have a class whose constructor is the following : I try to create an object of that class with the following lines : ( Of course ,... | < ? extends A > wo n't accept A 's child classes |
Java : I have a use case where I need to read a file and get the grouping of a sequence and a list of values associated with the sequence . The format of these records in the file are like sequence - val , example I want the output to be a map ( Map < String , List < String > > ) with the sequence as the key and list o... | Grouping By without using a POJO in java 8 |
Java : Looking at the java.util.Collections.unmodifiableMap implementation ( OpenJDK 11 ) : My question is why does the implementation not do a check that the map passed might already be an UnmodifiableMap , something like this : Rather this question can be extended to all other un-modifiable collections , a simple che... | Why does Collections.unmodifiableMap not check if the map passed is already an UnmodifiableMap ? |
Java : I need to get only the procedures using java DatabaseMetaData but this method returns also the functions ' names . <code> DatabaseMetaData dbmd=con.getMetaData ( ) ; ResultSet result = dbmd.getProcedures ( null , Ousername , null ) ; | Method to get only procedures from an oracle database using Java |
Java : I have two threads both of which accesses an Vector . t1 adds a random number , while t2 removes and prints the first number . Below is the code and the output . t2 seems to execute only once ( before t1 starts ) and terminates forever . Am I missing something here ? ( PS : Tested with ArrayList as well ) } Outp... | Writing to/Reading from a Vector ( or ArrayList ) with two threads |
Java : I 'm doing a project for a class which focuses on storing a huge matrix with mostly 0 values in memory and performing some matrix math on it . My first thought was to use a HashMap to store the matrix elements , and only store the elements which are non-zero , in order to avoid using huge quantities of memory.I ... | Why is it that , the more ' 1 ' bits in my Key , the longer it takes to place in the HashMap ? |
Java : I would like to cater for devices running on jelly bean version and below as well as versions above Jelly Bean.My method is supposed to get app usage/traffic for all applications based on the application ID . Please take noteof this line rx = Long.parseLong ( String.valueOf ( id ) ) ; on the first if clause whic... | Catering for devices running Jelly bean as well as versions later than Jelly bean when obtaining application data usage |
Java : I have two situations drawn up , and the strange differences between them are causing me a bit of grief . I will attempt to detail them below in code.Situation 1 : Situation 2 : Why , in situation one , is the runtime type of the parameter not used , but in situation two it is ? I understand that the examples ar... | Java -- Runtime typing differences |
Java : Can somebody tell me what does this mean ? I 'm going trough Java book and I 've encontered this example : What does Message ( ) { } Mean ? <code> public class Message { Message ( ) { } public Message ( String text ) { this.text = text ; } | Question about Java class constructor |
Java : I encountered this code wherein a method call , for example ClassA.search ( a , b , flag ) is being used by 3 Controllers . This is a simplified version of the method : Is this a good idea because code is reused ? Or is there a better way to still be able to make code reuse but not introduce this flag for method... | Is this a good way to reuse / share a method ? |
Java : Is this a bug or a feature ? The DateTimeFormatter JavaDoc explicitly states that when I use the OOOO pattern in my formatter , the full form of localized timezone should be used ( emphasis mine ) : Four letters outputs the full form , which is localized offset text , such as 'GMT , with 2-digit hour and minute ... | Why does the timezone pattern `` OOOO '' not show the full GMT+00:00 offset format ? |
Java : Basically question says it all.When I declare a function signature in gen-class , what type do I put for a 2D array of strings ? what do I put for XXXX ? Update : following @ Mark Topolnik 's suggestion , I 'm tryingin my declaration , and I 'm getting back a runtime exception when I try to compile it.Update 2 :... | How do I call a Clojure function that takes a two-dimensional array of Strings from Java ? |
Java : For the algorithm below : So for this algorithm , my thought process goes like this : The inner-loop performs n iterations for j when i=0 . However , for every value of i=0,1..n-1 , j will only perform one iteration because the if-statement will evaluate to true and end the inner-loop . Here is my source of conf... | Misunderstanding small details w/ nested for-loop time complexity analysis ... How to tell O ( n ) and O ( n² ) apart |
Java : I have a list of pencils and a list of erasers . The goal it to check whether or not all the erasers can be put on pencils . An eraser may fit on multiple different pencils . Pencils can have at most 1 eraser . If I just loop through all the erasers and put them on pencils , I end up with erasers that fit no uno... | Matching algorithm |
Java : Why do I get an error when But not in this case <code> int i=123 ; byte b=i ; final int i=123 ; byte b=i ; | Why there is no error when a final int is assigned to a byte |
Java : In Eclipse Neon , if I write this Java code : I get no leak warnings , but if I implement Stream , such asand I write similar codeI get a Resource leak : 'stream ' is never closed warning . This happens only in Eclipse , while compiling with javac does not issue any warning.Note I 'm not looking for an answer on... | Why does n't Eclipse show leak warning for streams ? |
Java : I 'm integrating with a payments processor and am trying to deal with the scenario where : user clicks pay and a request is made to our serverour server makes a request to the payment processorthere is a significant delay on the payment processor sideafter a certain threshold e.g . 60 seconds , we alert the user... | Interrupt if API call to payment processor takes over 60 seconds |
Java : The requirement is to automate the java webstart process . After clicking the JNLP file , its loading and displaying the below imageThere is no option for trust always here . I am aware of in Java 7 Update 51 , java tighten the security . So I have signed jars with public code signing certificate provided by sym... | Automate the webstart process |
Java : Recently I got a code review comment to use getter method for accessing private instance variable inside methods of same class . Is it really a good practice ? I feel that it is adding unnecessary complication in code . What is the recommended way ? <code> public class SomeClass { String abc ; public boolean com... | Is it a good coding practice to use getter for accessing private instance variables |
Java : I need to print the number of times the chain method reoccurs . <code> private static int chain ( int n ) { int count = 0 ; while ( n > 1 ) { if ( n % 2 == 0 ) { count++ ; //the value is not stored return chain ( n/2 ) ; } count++ ; //same thing return chain ( 3*n+1 ) ; } return count ; //prints the initial valu... | Any idea on how can I count the number of elements that verify an `` if '' condition ? |
Java : I 'll try to illustrate my problem in the following simplified example : Here I want to write generic method firstNotNull that returns DataHolder parametrized by common supertype of type parameter T of the this and other argument , so later I could write e.g . or The problem is that this definition of firstNotNu... | How can I use both method and class type parameters in single constraint ? |
Java : I 'm working on a new project , where I want to display some data on the screen . I set myself to using TDD which is new for me , but I love the idea and get along quite OK so far.I set up a JFrame , add a Textarea and put text there , but how can I properly test this ? Or is this wrong thinking in the TDD conte... | How to TDD a JFrame ? |
Java : If i autowire my generic class with different types in different controllers , does spring container create new instance for each ? Assume i have a generic class.In a controller i use and in another controller i use <code> @ Componentclass MyClass < T , K > { public K doStuff ( T t ) { // some logic here } } @ A... | Does spring container create new beans for the objects which belong to same generic class but use different types ? |
Java : So as it goes in the current scenario , we have a set of APIs as listed below : Over these , one of our schedulers performs the tasks e.g.While reviewing this , I thought of moving to a more flexible implementation 1 of performing tasks which would look like : The point that strikes my mind now is that the Javad... | Order guarantees using streams and reducing chain of consumers |
Java : I have created one service and broadcast receiver to get telephony state . Below is my code : I am facing below two issues1 ) i have printed log in code for different states , but all states are printing multiple times and audio file is also created multiple times for same call.2 ) if once i kill the app and sta... | Call recording , call multiple ( repetitive ) telephonic stages and creates multiple audio files |
Java : The question is : Why in this case i get compilation error in Java ? But this is legal : I use eclipse , jdk 7.Thank You <code> byte x = 0 ; x = 128 ; x+= 999l ; | Java operators interesting issue |
Java : I 've recently started benchmarking some Java code in order to get the best performance results for my program and noticed some strange thing . Namely , I 've benchmarked the following methods : and got those results : After searching over SO ( i.e . Is Math.max ( a , b ) or ( a > b ) ? a : b faster in Java ? ) ... | Why does inlining Math.max give over 200x slower code ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.