Inserting both words and integers into an array

I have searched for 30 minutes and did not find any answer regarding both words and values into an array.

So, I’m trying to build a deck of cards, and I want the value of the slot inside the array to be ” of clubs”, so that the value inside slot [4] would be: “5 of clubs”.

Is it possible? the array is defined as String.


This is my line (I know it’s wrong):
deck[j][k]=”(j+1) of clubs”;

when run, it outputs eight values. what are these values?

import static java.lang.System.out;
class A {      // by default, extends object
    protected int x = 0xF0;
    protected int z;
    public A() {
        z = fun ( x );
        out.printf ("%x", z);
    public int fun (int i) { return (i+1); }
    public static int staticFun (int i) { return (i + 3); }
class B extends A {
    protected int y = 0x11;
    public B() {
        z = fun ( z );
        out.printf (" %x ", z);
    public int fun (int i) { return ( i + 2 ); }
    public static int staticFun (int i) { return (i + 4); }
    public static void main (String args[]) {
        int i = 0; 
        A a = new B();
        out.print ( i ) + " ");
        out.println( a.staticFun (i) );
        B b = new B ();
        out.print ( i ) + " ");
        out.println( b.staticFun (i) );

when run it will outputs 8 values, i am not sure if have the output correct? for A it will return 1 and 3 because of the print and println of class A, and class B will return 2 and 4? And what are the other 4 values will return?

java jdbc xml sql condtional with in cdata

Hi I am very new to Java and have inherited a spring pattern. I want to know if there is a way to do a conditional in the xml.

Here is the scenario

      SELECT * FROM table WHERE a=:a

Here is what I want to do base on a global flag

      SELECT * FROM table WHERE a=:a
   <if global >
      AND b=:b

I am not sure about the syntax or it this is even possible inside of CDATA

Thanks in advance for any help.

NoSuchMethodError: No virtual method invoke in MethodHandle, Android

I am trying to use the MethodHandle on Android for a project. At the moment, I’m converting some existing Java code to be compatible with Android, but I’ve run into a problem.

In plain Java 7/8, the following compiles and prints “Jim”:

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

public class Example {

    public static void main(String[] args) throws Throwable {
        MethodHandle arrayReader = MethodHandles.arrayElementGetter(String[].class);

        Object array = new String[]{"Hi", "there", "Jim"};
        Object item = arrayReader.invoke(array, 2); 


The same code compiles for Android, but an exception is thrown at runtime:

java.lang.NoSuchMethodError: No virtual method invoke(Ljava/lang/Object;I)Ljava/lang/Object; in class Ljava/lang/invoke/MethodHandle; or its super classes (declaration of 'java.lang.invoke.MethodHandle' appears in /system/framework/core-oj.jar)

MethodHandle.invoke exists and uses the varargs feature to pass any number of Object arguments, yet at runtime it tries to find a method with arity 2 with parameter types Object and int.

I have tried replacing the invoke call with an array parameter: arrayReader.invoke(new Object[]{array, 2}), but this just creates another problem:

java.lang.UnsupportedOperationException: MethodHandle.invoke cannot be invoked reflectively.

I wouldn’t have expected this to work anyway, since the MethodHandle produced by the MethodHandles.arrayElementGetter call takes two arguments (the array and the index), but I thought it was worth a shot.

Is there any way to fix this, or an alternative method to achieve the same result?

Weblogic default persistent file store size issue

We are facing WL default persistent file store size increase issue on version 10.3.2. DAT file size got double every time it exception “javax.ejb.DuplicateKeyException: Bean with primary key” encountered. say if DAT file size is 600MB and exception raised size just got double i.e. 1.2 GB and server hangs. Setup Details:
JVM- 1.6 (32-BIT),
JMS Server and JMS queue in use,
Write Policy – Direct-Write (Default),
DB – Oracle DB (RAC),
Entity bean used for DB activity.

To recover server every time need to restart WL and backup DAT file as there is no provision found to empty DAT file at run time.

Appreciate any suggestion for the same.

when i login from postman i got the error like 401 authentication

public class LoginController {

private UserService userService;

@RequestMapping(value={"/logins"}, method = RequestMethod.GET)
public ModelAndView logins(@RequestBody User user, BindingResult bindingResult){
    ModelAndView modelAndView = new ModelAndView();
    return modelAndView;
@RequestMapping(value= {"/login"}, method=RequestMethod.POST)
public ModelAndView login(@Valid @RequestBody User user, BindingResult bindingResult){
    /*ModelAndView modelAndView = new ModelAndView();
    return modelAndView;*/
    ModelAndView modelAndView = new ModelAndView();
    User userExists = userService.findUserByEmail(user.getEmail());
    if (userExists != null) {
                .rejectValue("email", "error.user",
                        "There is already a user registered with the email provided");
    if (bindingResult.hasErrors()) {
    } else {
        modelAndView.addObject("successMessage", "User has been login successfully");
        modelAndView.addObject("user", new User());

    return modelAndView;

@RequestMapping(value="/admin/home", method = RequestMethod.GET)
public ModelAndView home(){
    ModelAndView modelAndView = new ModelAndView();
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    User user = userService.findUserByEmail(auth.getName());
    modelAndView.addObject("userName", "Welcome " + user.getName());
    modelAndView.addObject("adminMessage","Content Available Only for Users with Admin Role");
    return modelAndView;


public class Userserviceimpl implements UserService {

private UserRepository userRepository;
private RoleRepository roleRepository;
private BCryptPasswordEncoder bCryptPasswordEncoder;

public User findUserByEmail(String email) {
    return userRepository.findByEmail(email);


public void saveUser(User user) {

    Role userRole = roleRepository.findByRole("SUPERADMIN");
    user.setRoles(new HashSet<Role>(Arrays.asList(userRole)));;


public class WebMvcConfig extends WebMvcConfigurerAdapter {

public BCryptPasswordEncoder passwordEncoder() {
    BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
    return bCryptPasswordEncoder;


public class Role {

private int roll_id;

private String role;

public int getRoll_id() {
    return roll_id;

public void setRoll_id(int roll_id) {
    this.roll_id = roll_id;

public String getRole() {
    return role;

public void setRole(String role) {
    this.role = role;


My input in postman

if i send showing error like this
“timestamp”: 1508938909379,
“status”: 401,
“error”: “Unauthorized”,
“message”: “Full authentication is required to access this resource”,
“path”: “/login”

I have two table like user and role and user_role in mysql database.

Microserivce Using Spring Boot to Consume SOAP

I need to create a REST service that first consumes SOAP. What would the best way to go about this?

I would like to use Spring Boot to create a microservice, but I have a few questions for those with experience:

  • What other architectures or technologies should I look into using
    (with spring boot)?
  • Is there a standard technology stack for this?
  • Are there pitfalls I should be aware of?

Does WebDriverWait return an element in Java?

I’ve been writing tests with Java, and I use WebDriverWait like this:

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);

And my question comes up because I start to write test with Python, I come across WebDriverWait with Python like this:

element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "myDynamicElement"))

That means, WebDriverWait in Python waits and also returns an element at the same time. Can WebDriverWait in Java do the same, return an element? If it can, I have never known.

One to Many KStream-KStream join

How to perform one to many join between two kafka KStream?
The code given below joins two Kafka KStream which in a one to one manner.
Can someone guide so as how to perform a one to many join between KStream?
The data which is received in the topic is of generics < String ,JsonNode >
The data which is getting written in topic is of the form
{“from order”:”test1:,”from orderitem”:”test2″}
{“from order”:”test1:,”from orderitem”:”test3″}

Is it possible to get the data in this format:
{“from order”:”test1,{“from orderitem”:”test2″},{“from orderitem”:”test3″}}

public class ConsumerThreadPool {

private static final String TOPIC = "jre1";
private static final String NEXTTOPIC ="Kafka";
private static final String FINALTOPIC="jvm1";
private static final Integer NUM_THREADS = 1;
final Serializer<JsonNode> jsonSerializer = new JsonSerializer();
final Deserializer<JsonNode> jsonDeserializer = new JsonDeserializer();

final Serde<JsonNode> jsonSerde = Serdes.serdeFrom(jsonSerializer, jsonDeserializer);
final Serde<String> stringSerde = Serdes.String();

int threadNumber = 0;
private ConsumerConfigFactory consumerConfigFactory;

private ConsumerConnector consumer;
private ExecutorService threadPool;

public ConsumerThreadPool() {
    threadPool = Executors.newFixedThreadPool(NUM_THREADS);

public void startConsuming() {
    ConsumerConfig consumerConfig = consumerConfigFactory.getConsumerConfig();
    consumer = createJavaConsumerConnector(consumerConfig);
    KStreamBuilder builder = new KStreamBuilder();
    /* KTable<String,JsonNode> message = builder.table(stringSerde,jsonSerde,TOPIC);

    KTable<String,JsonNode> orderstream = message

            .filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER")
    KTable<String,JsonNode> orderlist=message.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER_ITEM"));,jsonSerde,FINALTOPIC); ,jsonSerde,FINALTOPIC);    */ 

    KStream<String,JsonNode> orderstream=streams.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER"))

    KStream<String, JsonNode> orderlist=streams.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER_ITEM"))

    KStream<String,JsonNode> nextstream =orderstream.join(orderlist,(new ValueJoiner<JsonNode,JsonNode,JsonNode>(){
        public JsonNode apply(JsonNode first,JsonNode second){
            ObjectNode jNode = JsonNodeFactory.instance.objectNode();
            return jNode.put("from order",first.get("op_type").textValue())
                    .put("from orderitem",second.get("op_type").textValue() );
    KafkaStreams stream=new KafkaStreams(builder, consumerConfigFactory.getConsumeConfig());

public void consume() {

    KafkaConsumer<String,String> consumer = new KafkaConsumer<>(consumerConfigFactory.createConsume());

    while (true) {
        ConsumerRecords<String, String> records = consumer.poll(100);
            System.out.println("ConsumerRecords object created: "+records);
            threadPool.submit(new MessageConsumer(records, threadNumber));