title: Arrange Words in descending order of their length
body: <p>Requirement:</p>
  <blockquote>
  <p>Write a program to accept a string and print the words in descending &gt; order of their length, <strong>without using arrays</strong>.</p>
  </blockquote>
  <p>example:</p>
  <blockquote>
  <p>Input=I love my country India</p>
  <p>Output=country India love my I</p>
  </blockquote>
  <p>I have tried to solve by using nested loop but it will take time for bigger inputs. suggest a better alternative algorithm...</p>
  <pre><code>//Input=I love my country India
  //Output=country India love my I
  public static void main(String[] JVJplus)
  {
      String s,temp=&quot;&quot;,newS=&quot;&quot;;
      int i,j;
      System.out.print(&quot;Entet s=&quot;);
      s=in.nextLine()+&quot; &quot;;
      for(i=s.length();i&gt;0;i--)
      {
          for(j=0;j&lt;s.length();j++)
          {
              char c=s.charAt(j);
              if(c!=' ')
                  temp+=c;
              else
              {
                  if(temp.length()==i)
                      newS+=temp+&quot; &quot;;
                  temp=&quot;&quot;;
              }
          }
      }
      System.out.println(&quot;Output=&quot;+newS);
  }
  </code></pre>