Skip to content
Advertisement

Tag: arrays

swap each element with its neighbour element in an array

I need to write a program. This method will take integer array as input and return array where each value is swapped with its neighbour element. In case the array has odd count, then last element is not swapped. Result: I tried using nested for loops but didnt get it Answer Where is the code you tried so far ?!

Cannot use setArray JDBC (integer) with H2 Database

I want to put an array of integers in my jdbc query with H2 database. But doest not work, I am getting this exception : org.h2.jdbc.JdbcSQLException: Data conversion error converting “(1,2,3)”; SQL statement: I am using H2 database. Can you help me please? Answer Using my JDBC utilities to work with JDBC IN array parameters easily: 1. If Maven, add

How to scale basic drawings?

I would like to have a list of shapes, that appears in my window. Whenever I’m changing the size of the window, I would like to scale all of my drawings. I already prepared classes, that store information about random shapes in a list (rectangles, ovals, etc.). I have no problem with painting them all, but I can’t deal with

How to dynamically declare shape of an Array in Java?

I am working with an API where I need to provide a Object[], Object[][], Object[][][]… you get the idea. Assume setFoo requires an Object[], this is how I get it to work: And this is how I make Object[][] requirement work, so that I can call setBar.. The problem is, I am not able to figure out how to create

MongoDB how to count array elements with Java driver

I need my application to count the size of an array foos inside a document using Java driver 3.8. I know I can do this with the shell but I have no idea of how to do this with java, because the only method producing a $size operator I found is Filters.size(String fieldName, int size) that is meant to look

Advertisement