mercredi 1 septembre 2021

Why does else if and else act different here?

When I do this,

      if(a>=b && a>=c) {
        max = a;

    } else if (b>=a && b>=c) {
        max = b;

    } else if (c>=a && c>=b) {
        max = c;

    }
    System.out.println(max);

It gives an error (java: variable max might not have been initialized), but when i do it like this,

    if(a>=b && a>=c) {
        max = a;

    } else if (b>=a && b>=c) {
        max = b;

    } else {
        max = c;

    }
    System.out.println(max);

It works. Why is it like that?

how can I "connect" two Strings of two different Comboboxes?

Why doesn't this work?

 String [] auswahlmöglichkeiten_währung2 = {"Euro", "Dollar", "Yen"};
    JComboBox zweite_Combobox = new JComboBox(auswahlmöglichkeiten_währung2);
    zweite_Combobox.setVisible(true);
    zweite_Combobox.setBounds(200,65,120,45);
    zweite_Combobox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

        }
    });

    String[] auswahlmöglichkeiten_währung = {"Euro", "Dollar", "Yen"};
    JComboBox erste_Combobox = new JComboBox(auswahlmöglichkeiten_währung);
    erste_Combobox.setVisible(true);
    erste_Combobox.setBounds(20, 65, 120, 45);
    erste_Combobox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == erste_Combobox) {
                JComboBox neue_Combobox = (JComboBox)e.getSource();
                String währung1 = (String)neue_Combobox.getSelectedItem();
                switch (währung1){
                    case "Euro":
                        if (e.getSource() == zweite_Combobox){
                            JComboBox neue_Combobox1 = (JComboBox)e.getSource();
                            String währung2 = (String)neue_Combobox1.getSelectedItem();
                            switch (währung2){
                                case "Euro":
                                    System.out.println("You picked euro two times");
                                    break;
                            }

What Im trying to do here is print out the line "You picked euro two times", but only if the user selected "Euro" in the first Combobox and in the second. There's no error, but doesn work. What did I do wrong or how can I "connect" two Strings of two different Comboboxes?

Conditional column in pandas

I am trying to create a new conditional column based on column A in the pandas dataframe. column A is a numeric column with values 0 - 50 and has some blanks

I need to create a conditional column with below logic

if column A is >= 50 then output "greater than 50" if column A is between 20 - 49 then "between 20 to 49" if column A is between 0 - 19 then "between 0 - 19 else blank

I am looking for something like an if query in java

Hello I have to work on an excel file and I want to do my work easier. I have to insert a shortcut to an associated number. For Example: If in row b is a "1" , i have to insert "ABC" in row E , if in row "b" is a 3, I have to insert "GHI" .

So i need something like an if- query in Excel. Thank you for your help.

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters while check in if condition

I am writing a if condition to find the element location in my project.

    if (!(driver.findElement(MobileBy.xpath(ObjRepoProp.getProperty("searchTextBox_XPATH"))).isDisplayed()
            || driver.findElement(MobileBy.xpath(ObjRepoProp.getProperty("routeOverview_XPATH"))).isDisplayed()
            || driver.findElement(MobileBy.xpath(ObjRepoProp.getProperty("scrollNavigationDrawer_XPATH")))
                    .isDisplayed())) {
        throw new IllegalStateException("This is not Destination Input page");
    }

In this code if one of the condition become true then also "org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters." trigger and testcases failed.

Trying to print out else statement but not working

HI I am trying to print this else statement but Java kept saying that it is not a statement anyone can fix this? enter image description here

SQL if statement for date range

Hi I was needing help with the syntax to add a condition where the current date is retrieved if today is after the 5th of each month but if its between the 1st to the 5th then it should retrieve the month before this month. Is it something you can help with please? Below is how my query is structured.

 Select * 
 FROM table1  
  left join  table2
       on e.ENTITY_NBR  = d.entity_nbr
     and cast(getdate() as date) between MONTH_BEGIN_DATE and MONTH_END_DATE