Home TechnologyProgramming Subscribe to RSS

Could You Write A Program To Accept A String As A Command Line Parameter And Print Length Of String?

Answer Question

1 Answer - Sort by: Date | Rating

    Public class CmdLine {
        public static void main(String[] args) {
            if (args.length <= 0) {
                System.out.printl parameters passed");
            } else {
                System.out.printl No of parameters passed is " + args.length);
                System.out.printl Below is the list of parameters passed along with each Parameters Length **");
                
                for (int i = 0; i < args.length; i++) {
                    System.out.printl " + i + " : " + args[i]);  
                    System.out.printl Its Length is : " + args[i].length() + "n");
                }           
            }
        }
    }
    0 0

    Rinav  

    answered 1 year ago

    Again the code vanishes....
    Well here u go...

    Public class CmdLine {
    public static void main(String[] args) {
    if (args.length
    Report
    Rinav

    Rinav

    commented 1 year ago

    Public class CmdLine {
    public static void main(String[] args) {
    if (args.length
    Report
    Rinav

    Rinav

    commented 1 year ago

    But the code uses already inbuilt function..........................if already existing functions are to be used then the same program can be written in two lines....
    Report
    Someone31

    Someone31

    commented 2 months ago

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International