Category "java"

Scanning multiple lines using single scanner object

I a newbie to java so please don't rate down if this sounds absolute dumb to you ok how do I enter this using a single scanner object 5 hello how do y

To check if a number is Armstrong number using java

this is my program: public class ArmstrongNumber { public static void main(String args[]) { int n = 0, temp = 0, r = 0, s = 0; Scanner in

How to set JAVA_HOME environment variable on Mac OS X 10.9?

I just purchased a brand new MacBook Pro. This is my first MAC ever and I'm still trying to get the hang of navigating my way around. Anyway, I'm also new t

How to do this string pattern aaabbc to be displayed as 3a2b1c in java 8 using streams

I want to display the String pattern aaabbcc to be displayed as 3a2b2c in java8 using streams I have a working example in lower versions String str = "aabbcccdd

Compiling multiple packages

I'm building a small Java project and must compile it from the command line and can't figure out how. The packages of the project are the following : Project +

How to run TestNG test several times with BeforeTest execution?

I try to execute the test several times with DataProvider. All works fine, but @BeforeTest and @AfterTest execute only one time, but I need this execution with

HttpPost: InputDispatcher: "Channel is unrecoverably broken and will be disposed!" on Nexus 7

On Nexus 7 (4.3), and not on my older device, LG Optimus 3d (Android 2.2), when I do HttpPost, I get this E/InputDispatcher﹕ channel '4273f7b0 ... Main

Would it be the right approach to close and open a new WebDriver session between negative tests in Selenium?

I close my driver and reopen it between each negative test, for example - in my negative login test - if the test failed it means the login succeeded, then I cl

How to run TestNG test several times with BeforeTest execution?

I try to execute the test several times with DataProvider. All works fine, but @BeforeTest and @AfterTest execute only one time, but I need this execution with

The FileReader cannot find my text file

I have a simple text file and for some reason, it cannot be found. I don't see anything wrong with the code because I got it from a site, and I am starting to t

How do I view source code of built-in classes in Java (e.g. BigInteger etc.)? [duplicate]

For example, during some compilation errors, I get access to some built in source codes where the error has occured (maybe the perimeters were

Java "VariableDeclaratorId expected after this token"

I'm working on a little project for fun, that's essentially a little combat emulator. I'm trying to use a class similar to struct in C++, as in using it to crea

spark elasticsearch: Multiple ES-Hadoop versions detected in the classpath

I'm new to spark. I'm trying to run a spark job that loads data to elasticsearch. I've built a fat jar from my code and used it during spark-submit. spark-subm

Counting unique characters in a String given by the user

I have to write a program that counts the uniques characters in a String given by the user. For example "abc" returns 3 and "aabbccd" returns 4. I am not allow

Where is javax.annotation

Ok, so this is probably a NooB question (I'm more of a C++ guy), but I'm lost in the java woods and its frameworks forests... I'm trying to look into eclipse R

How to Pass JSON in the body of GET Request in Rest Assured?

Trying to pass this JSON in the body of a get request in rest assured. Is creating a JSON object a way to go ? { "pharmacyListId": null, "pharmacyListNa

When using Immersive Mode with dialogs, nav. bar reappears and resizes my layout

I'm using Immersive Mode in my app when it's running on Android 4.4+. (http://developer.android.com/training/system-ui/immersive.html) My activity indeed shows

Incompatible operand types char and string - JAVA

The program compares a character to a String and counts the number of times that character repeats in the String. Line 8 gives error "Incompatible operand types

ARCore – Session, Frame, Camera and Pose

I'm studying the ARCore References, Develop, make the course from Coursera, and read, understood and learn from the Samples. But I still missing some definitio

Dynamodb attribute converter provider for enhanced type extending Hashmap

I have a type which is extending HashMap<String, String>. As per the documentation here, it is possible to add a custom converter for the type. But it see