Alright i need some help, been stuck on a basic task.

I input 2 strings. I need to be able to have it compare the two strings to see which one is shorter, then count how short the item is and out put the number.

ex. Word 1 Hello
word 2 hi
Output: the word with the least letters contains 2 letters.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication17;

import java.util.*;
/**
 *
 * @author Austin
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

                Scanner scan = new Scanner(System.in);
 int PW = 0; int i = 0;
     System.out.print("Enter Word one ");
     String password = scan.nextLine();
     System.out.print("Enter Word two ");
     String password2 = scan.nextLine();

     



System.out.println(" Shortest number is " +PW+ " letters");

    }
}

You have to create a method to compare the two strings

Which is just a single line of code :)

Got it thanks, do i start a new thread for a different issue or can i post it in here?

Post a new thread for a different topic. If the question you asked in here was answered, you should mark the thread as solved with the blue link at the bottom of the thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.