Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Java is dumb

Name: Anonymous 2009-09-27 22:23

Can someone tell me how I can turn a string like "http://www.google.com/" and return the protocol "http" by returning all characters before "://"? I tried using split but that gives me an array but we haven't even covered arrays yet so somehow I think I must be on the wrong track.

All I want is a god damn sub string using a string as the parameter

:<

Name: Anonymous 2009-09-28 16:01

I would do

String s = "http://www.google.com/";
String prot = "";
for (int i = 0; i + 2 < s.length(); i++) {
   if (s.charAt(i) == ':' && s.charAt(i + 1) == '/' && s.charAt(i + 2) == '/') {
      prot = s.subString(0,i);
      break;
   }
}

Name: Anonymous 2009-09-28 16:02

I would do

String s = "http://www.google.com/";
String prot = "";
for (int i = 0; i + 2 < s.length(); i++) {
   if (s.charAt(i) == ':' && s.charAt(i + 1) == '/' && s.charAt(i + 2) == '/') {
      prot = s.subString(0,i);
      break;
   }
}

Name: Anonymous 2009-09-28 16:06

Sorry for double post. Also, the line

prot = s.subString(0,i);

should be

prot = s.substring(0,i);

No clue why only this function doesn't follow java naming conventions.

Name: Anonymous 2009-09-30 19:21

String s = "http://www.google.com/";
String prot = s.split("://")[0];

Name: Mbt 2010-04-28 23:48

The Mbt are popular with both recreation and sportswear,Mbt shoes are simply matchless in terms of style, comfort and longevity,Mbt sale Now! Free Shipping! NO Tax!http://www.mbt-antishoes.net
The ghd iv styler offers you the opportunity to fashion,The ghd hair straighteners optimum performance wherever you travel,the ghd save up 50%  off,free shipping!no tax! http://www.ghdivstyle.com
The Christian Louboutin shoes is withstand all kinds of day to day pressures with great amounts of poise and yet strive ahead in life,christian louboutin sale fashion design to Show your special style,The Christian LouboutinHighlight the females gentle and lovely,http://www.christianlouboutindesigners.com

Don't change these.
Name: Email:
Entire Thread Thread List