long polling implementation in java
I have implement a long poll implementation. What happening is, when the request comes i check whether some data is available and if not sleep the thread and recursively call the method till data is...
View ArticleWhy is this code thread safe?
I am preparing for the OCP exam and I found this question in a mock exam: Given: class Calculator { private AtomicInteger i = new AtomicInteger(); public void add(int value) { int oldValue = i.get();...
View ArticleOverloaded function call choosing (int) over (Short) with a short parameter...
My class is as follows: public class Test1 { public static void go(Long n) { System.out.println("Long "); } public static void go(Short n) { System.out.println("Short "); } public static void go(int n)...
View ArticleHow do I escape the @ sign in Rythm?
I am using Rythm (yup no h), a Java template engine. The idea is to replace placeholders in a template file (e.g. a text file). In my case I am dealing with JSON. To call the Rythm engine I only need...
View Articlecall to web API from browser not working with Async action
I have created a web API that have the below async action [ActionName("getFedCust")] private async Task<HttpResponseMessage> getFedCust() { using (var client = new HttpClient()) {...
View Articlecall java class from SAS. ERROR: Could not find class
data Numbers; do i=1 to 10; output; end; run; data PrimeNumbers; set Numbers; if _N_=1 then declare javaobj j("C:\Program Files\Java\jdk1.7.0_10\bin\checkPrimeNumber");...
View Articlewhen calling a jframe class the second time it duplicates it but with no...
hello everyone i’m currently working on a school project and i’m experiencing a problem that occurs when i call a jframe class, whenever i call the simSimi.java in mainMenu.java at first it will call...
View ArticleHow to call a method in an If-statement inside an If-statement? (JAVA)
here’s my code: import java.util.Scanner; class test { public static void main(String[]args){ Scanner in=new Scanner(System.in); System.out.print("Enter disc to move: "); int disc=in.nextInt();...
View ArticleExecute jdbc call in spring mvc
In spring mvc when i execute the following command it shows error. Map<String,Object> out = simpleJdbcCall.execute(in); The error is : java.lang.NoSuchMethodError:...
View ArticleSpecial characters in Java. Can you use single quotes in this printf method...
I’m reading a textbook on Java and I encountered this passage. I had some questions. First, here are some special escaped characters that the book mentions. ’\n’ the newline character ’\t’ the tab...
View ArticleHow to properly write JUnit tests?
I’m a bit confused on how to properly write unit tests for my application. Actually i want to know if i have to rewrite an existed method and modify it for junit or just call my existed method and use...
View ArticleArrayList size shrinking by 1 upon each method call [duplicate]
This question already has an answer here: Is Java “pass-by-reference” or “pass-by-value”? 55 answers Quick question. I am currently making a synthetic division calculator and as a part of that I need...
View Articlec# Web Api service call with no return value – async processing
I am looking to create a Web Api c# fire and forget service that I can post a payload to and immediately return a success or failure based on some initial checks, but then do the rest of the heavy...
View ArticleDial a number by tapping a TextView Android [duplicate]
This question already has an answer here: Dialing a phone call on click of textview in android 5 answers I have a page in my app that deals with contact information. I want to be able to tap a TextView...
View ArticleCreating objects (JTextfields) inside loop with diferent names
Is it possible to create multiple JTextFields with different names inside a loop? I need to so this since I later need to get the text that is in each of them, I need to do something like this: while...
View ArticleCreate instance of call with autowire
I have to create a instance of a class, that have autowired elements, for test. public class MyClass extends SomeOtherClass { @Autowired public MyClass(OtherClass1 one, OtherClass2 two){ super(one,...
View ArticleReturn the incremented value after recursiv call of the method
I am trying to return the depth of the string in the radix tree after finding the string in the radix tree but I am always getting the value 2. How can I keep storing the value of counter after...
View ArticleCalling DLL in VB.Net using Pinvoke is giving PInvokeStackImbalance Exception...
This question already has an answer here: Why are Cdecl calls often mismatched in the “standard” P/Invoke Convention? 2 answers I am trying to call a dll in VB.Net 2010 using PInvoke but I keep getting...
View ArticleA java class method can call another java class method. Then why do you need...
Servlets are java classes. A java class method can call another java class method. Then why do you need RequestDispatcher? The post A java class method can call another java class method. Then why do...
View ArticleHow do I call an ArrayList method from another class?
I’m in the process of creating a text UI for an ArrayList class, and I’m trying to create the methods in the second class that call the ArrayList methods. However when I’m trying to call a method that...
View Article