Practice-stretch - else news = news + "...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import apsc142.*;// The "Practice" class. public class Practice { public static String stretch (String s){ String news = ""; int lstring = s.length (); if (lstring > 1){ for (int i = 0; i <=(lstring*2-2); i++){ if (i%2==0) news = news +s.substring (i/2, i/2+1);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else news = news + &quot; &quot;; } } else news = s; return news; } public static void main (String args) { String test = &quot;abcdefgh &quot;; String result = stretch(test); System.out.println (result); } // main method } // Practice class...
View Full Document

Ask a homework question - tutors are online