Ninth season seventh episode,Ross sang a inappropriate song for Emma????

SCENE:
Ross and Rachel's apartment. Ross is playing with Emma on the couch after just changing her diaper.

Ross: And that's why, no matter what mommy says, we really were on a break. (baby talk.) Yes we were! Yes we were! (picks Emma up.) Come here gorgeous. (puts her on his knees and talks to her.) Oh! Look at you! You are the cutest little baby ever! You're just a… a little bitty baby, you know that? But you've got… (in a softer voice.) You've got big beautiful eyes… Yes you do… and a… and a big round belly. (emphasises the B's.) Big baby butt! I like big butts. (raps.) I like big butts and I cannot lie / you other brothers can't deny / when a girl walks in with an itty, bitty, waist / and a round thing in your face you get…(Emma laughs.) Oh my God, Emma… you're laughing! Oh my God, you've never done that before, have you? You never done that before… Daddy made you laugh, huh? Well, daddy and Sir Mix Alot… What? What? You… you wanna hear some more? Uhm…(raps.) My anaconda don't want none / unless you got buns hon… (Emma laughs again and Ross looks worried.) I'm a terrible father!

OPENING CREDITS

SCENE:
Central Perk. Joey sits at a table and Chandler and Monica enter.

Chandler: Hi!

Joey: Hey… hey listen… What do you guys know about investments?

Chandler: How come?

Joey: Well, I'm starting to make good money on the show and I'm thinking… I should probably do something with it.

Monica: What do you do with your money now?

Joey: Well, I just tape it to the back of my toilet tank. (realises that anyone could have overheard that.) I didn't say that! It's in a bank guarded by robots!

Chandler: Do you have any ideas?

Joey: Uh, yeah… This guy at work got me excited about going in on an emu farm. That'd be kinda cool huh? Pitching in on the weekends, helping to plant the emus…

Monica: Joe… Emus are birds. You raise them for meat.

Joey: (laughs.) Yeah! Right! (points at Monica.) People eat birds… Bird meat… Now do they just fly into your mouth or you go to… you go to a restaurant and you say: "Excuse me, I'll have a bucket of fried bird. " (laughs again.) Or… or maybe just a wing or… (realises…)

Monica: Joey, I think you should consider something a little less risky. I mean, I think in this market, real estate is your best investment. The Fed just lowered the rates and the interest on your mortgage is totally deductible. (looks at Chandler.) That's right, I know some stuff!

Joey: Real estate, huh? Hmmm…

Monica: (very excited.) Oh, and you know who's selling a great apartment? Richard!

Chandler: (imitating Monica.) Oh, and you know whose knowledge of her ex-boyfriend is shocking? Monica!

Monica: My dad told me. They play golf together.

Chandler: Oh, well… Maybe I'll join them some time. I just hope the club doesn't slip out of my hand and beat the moustache off his face.

SCENE:
Monica and Chandler's apartment. Rachel and Monica are sitting at the dinner table and Phoebe enters, knocking on the door.

Phoebe: Hi!

Rachel and Monica: Hey!

Phoebe: Listen! You have to help me pick a dress 'cause I'm meeting Mike's parents tonight! (Rachel gasps.)

Monica: Wow, the boyfriend's parents! That's a big step.

Phoebe: (sarcastically.) Really? That hadn't occurred to me.

Monica: They just gonna love you, just be yourself.

Phoebe: They live on the upper east side on Park Avenue!

Rachel: Oh yeah, she can't be herself.

Phoebe: Okay, so… all right… Which dress? (she holds up two 'Phoebe' dresses, Rachel and Monica look at them… taking their time, don't wanting to hurt Phoebe.) You can say "neither".

Rachel and Monica: Oh God, neither!

Monica: I'm sorry honey, but we're gonna take you shopping. It's gonna be fine.

Rachel: Yeah, totally! You are in such good hands. And I'm so good with meeting parents. With the father, you know, you want to flirt a little bit, but not in a gross way. Just kind of like: "Oh Mr. Pincer, I can see where Wallis gets his good looks…"

Monica: You went out with Wallis Pincer?

Rachel: Uh, he took the SAT's for me.

Monica: I knew you didn't get a 1400!

Rachel: Sssh yeah, well, duh! I mean…

Phoebe: So… now… What about with Mike's mom?

Rachel: Oh, with the mother, just… just constantly tell her how amazing her son is. Take it from me, moms love me. Ross's mom one time actually said I'm like the daughter that she never had.

Monica: (Monica looks at Rachel in disbelief.) She said WHAT?

Phoebe: (speaking louder and articulating.) That's she's like the daughter she never had. (Phoebe points at her ears.) Listen! (Monica looks at Phoebe in a duh! way.)

SCENE:
Ross and Rachel's apartment. Rachel enters the apartment.

Rachel: Hi.

Ross: Hi.

Rachel: I just finished getting Phoebe all dressed to meet Mike's parents. She's so nervous, it's so sweet!

Ross: Guess what? I made Emma laugh today.

Rachel: (in disbelief.) You WHAT? And I missed it? Because I was giving a makeover to that stupid hippie?

Ross: Yeah, and it was uhm… it was like a real little person laugh too. It was… it was like uhm… (Ross tries to impersonate Emma's laugh, but it comes out very squeaky, very high pitched. He laughs about himself but then looks at Rachel, realises that it sounded weird and straightens his face.) Only… only not creepy.

Rachel: Well… well, what did you do to make her laugh? (excited.)

Ross: I uhm… Well, I sang… (Rachel gasps.) well actually I rapped… Baby Got Back… (Rachel's face changes from excited to angry.)

Rachel: You WHAT? You sang… to our baby daughter… a song about a guy who likes to have sex with women with giant asses?

Ross: But you know what, if you think about it, it actually promotes a healthy uhm… body image… because… even big butts or uhm… juicy doubles.

Rachel: (disgusted.) owwwww…

Ross: Please don't take her away from me!

SCENE:
Richard's apartment. There's a knock on the door. The listing agent opens the door for Chandler and Joey.

Catherine: Oh hi, come on in. I'm Catherine, the listing agent.

Joey: Hi I'm Joey. This is Chandler.

Chandler: So how come Richard's selling the place? Went bankrupt? Medical malpractice? Choked on his own moustache?

Catherine: Actually, he is buying a much bigger place. It's got a great view of Central Pa…

Chandler: (interupting.) Mmm That's enough about you!

Joey: Is there anything we should know about the apartment?

Catherine: All the appliances are included. There is a lot of light, a new kitchen… I think you guys would be very happy here… (Joey and Chandler both realize what she's assuming and start laughing.)

Chandler: No, no, no, no, no, NO! No, no… we're not together. We're not a couple. We're definitely not a couple.

Catherine: Oh… Okay, sorry!

Joey: Well, you seem pretty insulted by that. What? I'm not good enough for you?

Chandler: We're not gonna have this conversation again… Look at this place. Why am I so intimidated by this guy? Pretentious art, this huge macho couch. When we know all he does is sit around all day crying about losing Monica to a real man! (laughs.) You don't think he's here, do you? (Joey looks around.)

Joey: You know what it is? It's a nice place but I gotta see, I don't know if I see myself living here. Oh, oh, oh, let me see… (Joey sits down on the couch, mimes opening a can and puts his hand down his pants.) Yeah, I could see it.

Chandler: (Chandler looks around the place and his eye gets caught by Richard's video collection.) Look at these videos. You know, I mean, who does he think he is? Magnum Force, Dirty Harry, Cool Hand Luke… Oh my God!

Joey: What?

Chandler: There's a tape here with Monica's name on it.

Joey: Ooh! A tape with a girls name on it. It's probably a sex tape… (realises.) Wait a minute… This says Monica… (looks around.) And this is Richard's apartment… (realises some more.)

Chandler: Get there faster! (Joey gasps and finally understands…)

SCENE:
Mike's parents building. Phoebe gets out of the classy elevator, looking all dressed up like an older woman, and very un-Phoebe. She walks to the door and rings the doorbell.

Mike: Wow! You look like… like my mom.

Phoebe: I'm wearing pantyhose!

Mike: Great! Come on in! (Mike kisses her on the cheek. A butler walks in and takes Phoebe's coat.)

Phoebe: Oh, thank you! Oh… Oh my God, you're RICH!

Mike: No, my parents are rich.

Phoebe: Yeah, so… They gotta die someday. (Mike's parents walk in.) HELLO!

Mike: Mom, dad, this is Phoebe. Phoebe, these are my parents: Theodore and Bitsy.

Phoebe: (in a very posh accent.) Theodore… Bitsy… What a delight!

Bitsy: It's so nice to finally meet you!

Phoebe: And you… Your home is lovely.

Bitsy: Well thank you, I'll give you a tour later. It's actually three floors.

Phoebe: Holy crap!

Bitsy: Phoebe, why don't you come in the living room and meet our friends?

Phoebe: Oh, try and stop me!

Mike: Hey… Wh… What are you doing?

Phoebe: (no accent.) I'm trying to get your parents to like me.

Mike: Yeah, I'm sure they will, but you don't have to do this… I'm wanting them to get to know Phoebe, not (accent.) Phoebe…

Phoebe: (accent.) Got it! It… It's hard to stop…

Mike: Well, come on…

Theodore: Phoebe, these are our friends, Tom and Sue Angle.

Bitsy: Phoebe, come sit. Tell us a little bit about yourself… So where are you from?

Phoebe: (no accent.) Uhm… Okay, well, all right, uhm… Originally I'm from upstate, but uhm… then my mom killed herself and my stepdad went to prison, so… I just moved to the city where uhm… I actually lived in a burned out Buick LeSabre for a while… (frowns are received.) which was okay, that was okay, until uhm… I got hepatitis, you know, 'cause this pimp spit in my mouth and… but I… I got over it and uhm… anyway, now I'm uhm… a freelance massage therapist, uhm… which, you know, isn't always steady money but at least I don't pay taxes, huh… (everyone in the room finds it a bit surreal, which Phoebe realizes and starts to talk in the accent again.) So… where does everyone summer?

Commercial Break

SCENE:
Mike's parents house again.

Phoebe: God! God! This is not going well.

Mike: No, no, no, you're doing fine, really… Why don't you go talk to my dad?

Phoebe: Okay, okay, okay, okay… Still sure about me being myself?

Mike: Absolutely! Or maybe just a little less pimp spit.

Phoebe: So Theodore… I uhm… I can see where Mike gets his good looks from…

Theodore: Oh… Well…

Phoebe: Yeah… And that physique! You must work out all the time…

Theodore: Oh no, not all the time… I do the best I can…

Phoebe: Yeah I bet! Look out! (Phoebe punches Theodore right in the stomach.)

Theodore: OH! OWWWWW! (Theodore grabs his stomach in agony.)

Phoebe: Oh my God, are you okay?

Theodore: I recently had surgery.

Phoebe: I'm so sorry!

Theodore: No, I'll be fine… I just should check the stitches…

Phoebe: I really, really am sorry.

Theodore: How could you know. Why wouldn't you punch me in the stomach? (Theodore walks out… Mike walks towards Phoebe.)

Mike: Uhm… Did you just hit my dad?

Phoebe: Yes… I'm sorry, I've never met a boyfriends parents before…

Mike: But, I mean, you have met… humans before, right? Look, why don't you go talk to my mom?

Phoebe: Yeah okay… yeah, your mom… okay… She looks nice, I can talk to her.

Mike: Yeah, you do that, and I go check my dad for signs of internal bleeding. (Mike walks away and Bitsy walks in the same direction.)

Phoebe: Yeah… Oh Bitsy, hi. Uhm… listen I just wanted to thank you again for having me here tonight.

Bitsy: Well, not at all…

Phoebe: Also uhm… I just want you to know what a wonderful man your son is.

Bitsy: Thank you, I think so too.

Phoebe: Well, and you know, it really is a testament to how he was raised. Especially to you. Because he's very respectful of women.

Bitsy: Is he really?

Phoebe: Are you kidding. He is so considerate of my feelings and… you know I think… you'd also like to know that he is a very gentle lover.

Bitsy: E-e-excuse me?

Phoebe: (Mike now enters and stands behind Phoebe.) Oh no, no, no, no, no, no. Don't get me wrong. No, he's not in like a sissy way. No, no, no… when he gets going, he can rattle a headboard like a sailor on leave…

Bitsy: That's… my boy. (Bitsy walks away.)

Mike: Awesome!

SCENE:
Monica and Chandler's apartment. Only Chandler is there with the videotape in his hands, standing in front of the TV set.

Chandler: I'm not gonna watch it… I don't NEED to watch it… I mean, what good could possibly come from watching? (sighs.) Well, we know I'm gonna watch it. (Chandler moves to put the tape in the VCR and Joey enters the apartment.)

Joey: Hey dude, what's up?

Chandler: Don't judge me, I'm only human!

Joey: Did you take that tape?

Chandler: I had to! Okay, imagine you were married… and you found a tape of your wife in another guys' apartment… Wouldn't you need to know what was on it?

Joey: I don't know. Who'm I'm married to?

Chandler: Some girl…!?

Joey: She hot?

Chandler: Yeah…!?

Joey: How did she get me to settle down?

Chandler: All right, I'm gonna watch it… I mean look, it's probably not even what I think it is… And even if it is… It can't possibly be as bad as what I'm picturing in my head… (laughs nervously.) Can it?

Joey: Guess I don't know. My experience: if a girl says yes to being taped… She doesn't say no to much else, I tell ya…

Chandler: Then you're gonna have to watch it for me.

Joey: (backs off.) What? Whoo… What?

Chandler: Just for a few seconds, so I can know what it is… Please?

Joey: All right, fine… But if I enjoy this, you have only yourself to blame… (Chandler turns his back to the TV. Joey puts the tape in the VCR, switches it on and watches what's on the tape… It's clearly an American football match, with the referee's whistle blowing, the crowds cheering…)

Chandler: Why am I hearing cheering?

Joey: Well it's okay, its like… its just a football game.

Chandler: Football? Just football?

Joey: Yeah, see… you were all worried for nothing.

Chandler: It's football… It's just football… This is great! This is the first time I've ever enjoyed football… It may be customary to get a beer… (Chandler walks to the fridge, his back turned to the TV and a moaning sound replaces the cheering of the crowd… Joey's eyes double in size…) What the… (Chandler turns around, but Joey already took a sprint for Chandler, jumps, and floors Chandler in the open space in front of the apartment door…) What are you doing?

Joey: You don't wanna see what I just saw! (at this moment Monica comes home, and sees Chandler flat on his back on the floor and Joey pinning him down.)

Monica: What are you guys doing? (Monica hears the moaning coming from the TV and looks at it.) Oh my God, is that Richard? (It only takes a split second for Joey to realize, he pulls Monica down by her jacket, and she falls, face down next to Chandler. Chandler gets up a bit, and Joey quickly covers Chandler's eyes with his hand.)

SCENE:
Ross and Rachel's apartment. Emma is sitting in her chair on the apothecary table and Rachel is trying to make her laugh.

Rachel: Okay… aahhh… Please laugh for mommy… Please? Please laugh for mommy… (Rachel makes a funny face, sticking her tongue out, making a farting noise and using her hands as antlers, wiggling her fingers… No response from Emma…) Not funny huh? Oh so, is it… only offensive novelty rap? Or maybe just, you know, rap in general? 'Cause mommy can rap… (Rachel tries to rap and makes weird movements with her arms in the process.) My name is mommy and I'm here to say / that all the babies are… Oh, I can't rap… All right sweetheart… This is only because I love you so much, and I know that you're not gonna tell anybody… (Rachel's face like, "Oh what am I doing? The things I have to go through… " and she starts to rap.) I like… big butts and I cannot lie… / You other brothers can't deny… / when a girl walks in with an itty bitty waist and a round thing in your face… (Emma starts to laugh.) Yes! Yes! Yes! YES! Oohhhhh! Oh! (Rachel now really gets into it, and her insecure movements start getting better.) I like big butts and I cannot lie… / You other brothers can't deny… Oh Emma you're laughing! Oh you are, you really do like big butts, don't you. Oh you beautiful little weirdo… (Rachel picks up Emma and Ross now enters.)

Ross: Hey!

Rachel: Oh you missed it. She was laughing. Oh it was amazing. It was amazing. It was the most beautiful, beautiful sound that…

Ross: Oh I know, isn't it? Ooh… what'd you do to get her to laugh?

Rachel: Oh! You know, I just… couple of things I tried … I just sang a little doo… Itsy Bitsy Spider…

Ross: You sang Baby Got Back didn't you?

Rachel: Nothing else worked. That girl is all about the ass…

SCENE:
Mike's parents house, the dining room. Mike, Phoebe, Mike's parents and the Angles are there.

Phoebe:…and then it goes back to the chorus… Smelly cat, Sme-lly ca-t / I-t's not your fau-lt. And that's the end of the song… I realise that you didn't ask to hear it, but uhm… no-one had spoken in seventeen minutes.

Mike: Phoebe writes lots of great songs. Wha… What was that one you sang the other night that everybody just loved?

Phoebe: Oh, Pervert Parade?

Mike: (sighs.) No…

Phoebe: Oh, Ode To A Pubic Hair?

Mike: Stop! (The butler serves dinner.)

Phoebe: Oh God! Is that veal?

Mike: Mom, I thought I told you… Phoebe's a vegetarian.

Bitsy: Oh!

Phoebe: Oh no, no, no, no… That's okay, that's okay… I mean, I'm… I am a vegetarian… except for veal… Yeah no, veal I love…

Mike: Phoebe you don't have to eat…

Phoebe: No, no, no, I actually it's any baby animals: kittens, fish babies… You know… especially veal… and this, this nice vein of fat running through it… (she cuts the meat, picks it up with her fork and holds it in front of her mouth, which she keeps closed, trying to overcome her vegetarian thoughts… and… puts it in her mouth… Clearly not enjoying the meat…) Hmmm… yummy (everybody seems okay with it, except Mike. He's making a hmmmm… face… Then Phoebe swallows it.) Hmmm… (at first she likes it, but then, in an instant puts her hand in front of her mouth and runs from the table. You hear a door slamming.)

Mike: So…? What do you think? (looks at his parents, who look disgusted.)

SCENE:
Monica and Chandler's. Monica switches off the VCR. Joey and Chandler are behind the couch.

Monica: So you stole that tape from Richard's apartment?

Chandler: Whoho ho… Listen to the judgment from the porn star!

Monica: That tape was never meant to be seen by… (pauses.) Joey I would feel more comfortable if I was having this conversation in private.

Joey: (laughs.) Monica, look… I don't think you and I have any secrets anymore… (Monica keeps looking at Joey.) Not ready to joke about it yet, okay, I see you later. (Joey walks out.)

Monica: Why in the world would you take this tape and and why would you watch it?

Chandler: Because that's who I am, okay? I'm sure a mature man like Richard could see a tape like that and it wouldn't bother him. Just'd be another saucy anecdote for him to share at his men's club over brandy and moustaches.

Monica: Is all this about you not being able to grow a moustache?

Chandler: This is about you and Richard. He's clearly not over you. He keeps a tape so he can… look at it whenever he wants.

Monica: Isn't that sad? I mean, can you see how pathetic that is? You shouldn't be jealous. You should feel bad for him.

Chandler: Oh, yeah, well, poor Richard. Y'… I can grow a moustache!

Monica: Chandler, this is not our problem. We've got each other. That's all that matters.

Chandler: Yeah, oh, but I just keep picturing you rolling around with him with your cowboy boots in the air…

Monica: Cowboy boots? I've never worn cowboy boots in my whole life! (she turns on the video again.)

Chandler: Oh, good, good. Play more, 'cause I wanna see how it ends.

Monica: THAT'S NOT ME!

Chandler: What…? That's not you! Life is good again! Ride 'em cowgirl!

Monica: That bastard taped over me! (Chandler's expression changes.)

Chandler: Is that a problem?

Monica: I-It's just so insulting! Big spring for a new blank tape, Doctor!

SCENE:
Mike's parents house. Dining room again. Both Mike and Phoebe are not at the table, but the others still are.

Theodore: I can't imagine what he sees in her.

Bitsy: She actually makes me miss that pill-popping ex-wife of his. (Mike walks in.) Oh, hello dear…

Mike: Hey, what's going on?

Bitsy: We were just chit-chatting. How's your friend?

Mike: A little better.

Bitsy: By the way, do you know who's moving back into town? Tom and Sue's daughter Jen.

Theodore: You remember her Michael, she's lovely and… well-behaved and… single.

Mike: I'm not interested.

Bitsy: Oh, please darling, let's be honest. You can have all the… sailor fun you want with that one, but… let's be real…

Mike: All right, stop! You know, all Phoebe has done tonight is trying to get you to like her. And maybe that hasn't been clear all the time, but she did her best. And yeah… She's a little different than you are…

Bitsy: Michael, a pimp spit in her mouth! (Phoebe almost enters the room, but she hears the discussion and waits and eavesdrops next to the door-opening.)

Mike: So what? I mean if even I can get past that, it shouldn't bother you. And you don't have to like her. You just have to accept the fact that I do. I mean, if you even can't be civil to the woman I love…

Bitsy: The woman you what? (Phoebe overheard what Michael said and now enters the room.)

Phoebe: Yeah… The woman you what?

Mike: The woman I love… (he walks to Phoebe.) I love you… Which is probably something I shouldn't say for the first time in front of my parents… and Tom and Sue…Who are by the way the most sinfully boring I've ever met in my life…

Phoebe: I love you too…

Mike: You do?

Phoebe: YEAH…! How great is this…? (they kiss.)

Mike: Wanna get out of here?

Phoebe: Okay.

Mike: Mom, dad, thanks for dinner.

Phoebe: I had a great time. (accent.) It was really top drawer. And here's something rich: thirteen bathrooms in this place… I threw up in the coat closet… Ta taaa…

Commercial Break

SCENE:
Ross and Rachel's. Emma is in her bed and Ross and Rachel are rapping and dancing for her.

Ross: She sweat, wet, got it going like a turbo 'vette.

Rachel: So fellas

Ross: Yeah!

Rachel: fellas

Ross: Yeah!

Rachel: Has your girlfriend got the butt?

Ross: Hell yeah!

Rachel: So shake it! (Rachel slaps Ross's butt on the beat.)

Ross: Shake it!

Rachel: Shake it! (Phoebe, Mike, Chandler, Monica and Joey step in.)

Ross: Shake it!

Rachel: Shake that nasty butt…

Ross: Baby got back (Then Ross turns around and sees their friends standing in the doorway.)

Rachel: One more time from the top… I like big butts and I cannot lie, you other br… (She also turns and sees the gang.)

Ross: Rachel please! That is so inappropriate!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1JAVA SE 1.1深入JAVA API 1.1.1Lang包 1.1.1.1String类和StringBuffer类 位于java.lang包中,这个包中的类使用时不用导入 String类一旦初始化就不可以改变,而stringbuffer则可以。它用于封装内容可变的字符串。它可以使用tostring()转换成string字符串。 String x=”a”+4+”c”编译时等效于String x=new StringBuffer().append(“a”).append(4).append(“c”).toString(); 字符串常量是一种特殊的匿名对象,String s1=”hello”;String s2=”hello”;则s1==s2;因为他们指向同一个匿名对象。 如果String s1=new String(“hello”);String s2=new String(“hello”);则s1!=s2; /*逐行读取键盘输入,直到输入为“bye”时,结束程序 注:对于回车换行,在windows下面,有'\r'和'\n'两个,而unix下面只有'\n',但是写程序的时候都要把他区分开*/ public class readline { public static void main(String args[]) { String strInfo=null; int pos=0; byte[] buf=new byte[1024];//定义一个数组,存放换行前的各个字符 int ch=0; //存放读入的字符 system.out.println(“Please input a string:”); while(true) { try { ch=System.in.read(); //该方法每次读入一个字节的内容到ch变量中。 } catch(Exception e) { } switch(ch) { case '\r': //回车时,不进行处理 break; case '\n': //换行时,将数组总的内容放进字符串中 strInfo=new String(buf,0,pos); //该方法将数组中从第0个开始,到第pos个结束存入字符串。 if(strInfo.equals("bye")) //如果该字符串内容为bye,则退出程序。 { return; } else //如果不为bye,则输出,并且竟pos置为0,准备下次存入。 { System.out.println(strInfo); pos=0; break; } default: buf[pos++]=(byte)ch; //如果不是回车,换行,则将读取的数据存入数组中。 } } } } String类的常用成员方法 1、构造方法: String(byte[] byte,int offset,int length);这个在上面已经用到。 2、equalsIgnoreCase:忽略大小写的比较,上例中如果您输入的是BYE,则不会退出,因为大小写不同,但是如果使用这个方法,则会退出。 3、indexOf(int ch);返回字符ch在字符串中首次出现的位置 4、substring(int benginIndex); 5、substring(int beginIndex,int endIndex); 返回字符串的子字符串,4返回从benginindex位置开始到结束的子字符串,5返回beginindex和endindex-1之间的子字符串。 基本数据类型包装类的作用是:将基本的数据类型包装成对象。因为有些方法不可以直接处理基本数据类型,只能处理对象,例如vector的add方法,参数就只能是对象。这时就需要使用他们的包装类将他们包装成对象。 例:在屏幕上打印出一个*组成的矩形,矩形的宽度和高度通过启动程序时传递给main()方法的参数指定。 public class testInteger { public static void main(String[] args) //main()的参数是string类型的数组,用来做为长,宽时,要转换成整型。 { int w=new Integer(args[0]).intValue(); int h=Integer.parseInt(args[1]); //int h=Integer.valueOf(args[1]).intValue(); //以上为三种将字符串转换成整形的方法。 for(int i=0;i<h;i++) { StringBuffer sb=new StringBuffer(); //使用stringbuffer,是因为它是可追加的。 for(int j=0;j<w;j++) { sb.append('*'); } System.out.println(sb.toString()); //在打印之前,要将stringbuffer转化为string类型。 } } } 比较下面两段代码的执行效率: (1)String sb=new String(); For(int j=0;j<w;j++) { Sb=sb+’*’; } (2) StringBuffer sb=new StringBuffer(); For(int j=0;j<w;j++) { Sb.append(‘*’); } (1)和(2)在运行结果上相同,但效率相差很多。 (1)在每一次循环中,都要先将string类型转换为stringbuffer类型,然后将‘*’追加进去,然后再调用tostring()方法,转换为string类型,效率很低。 (2)在没次循环中,都只是调用原来的那个stringbuffer对象,没有创建新的对象,所以效率比较高。 1.1.1.2System类与Runtime类 由于java不支持全局函数和全局变量,所以java设计者将一些与系统相关的重要函数和变量放在system类中。 我们不能直接创建runtime的实例,只能通过runtime.getruntime()静态方法来获得。 编程实例:在java程序中启动一个windows记事本程序的运行实例,并在该运行实例中打开该运行程序的源文件,启动的记事本程序5秒后关闭。 public class Property { public static void main(String[] args) { Process p=null; //java虚拟机启动的进程。 try { p=Runtime.getRuntime().exec("notepad.exe Property.java"); //启动记事本并且打开源文件。 Thread.sleep(5000); //持续5秒 p.destroy(); //关闭该进程 } catch(Exception ex) { ex.printStackTrace(); } } } 1.1.1.3Java语言中两种异常的差别 Java提供了两类主要的异常:runtime exception和checked exception。所有的checked exception是从java.lang.Exception类衍生出来的,而runtime exception则是从java.lang.RuntimeException或java.lang.Error类衍生出来的。    它们的不同之处表现在两方面:机制上和逻辑上。    一、机制上    它们在机制上的不同表现在两点:1.如何定义方法;2. 如何处理抛出的异常。请看下面CheckedException的定义:    public class CheckedException extends Exception    {    public CheckedException() {}    public CheckedException( String message )    {    super( message );    }    }    以及一个使用exception的例子:    public class ExceptionalClass    {    public void method1()    throws CheckedException    {     // ... throw new CheckedException( “...出错了“ );    }    public void method2( String arg )    {     if( arg == null )     {      throw new NullPointerException( “method2的参数arg是null!” );     }    }    public void method3() throws CheckedException    {     method1();    }    }    你可能已经注意到了,两个方法method1()和method2()都会抛出exception,可是只有method1()做了声明。另外,method3()本身并不会抛出exception,可是它却声明会抛出CheckedException。在向你解释之前,让我们先来看看这个类的main()方法:    public static void main( String[] args )    {    ExceptionalClass example = new ExceptionalClass();    try    {    example.method1();    example.method3();    }    catch( CheckedException ex ) { } example.method2( null );    }    在main()方法中,如果要调用method1(),你必须把这个调用放在try/catch程序块当中,因为它会抛出Checked exception。    相比之下,当你调用method2()时,则不需要把它放在try/catch程序块当中,因为它会抛出的exception不是checked exception,而是runtime exception。会抛出runtime exception的方法在定义时不必声明它会抛出exception。    现在,让我们再来看看method3()。它调用了method1()却没有把这个调用放在try/catch程序块当中。它是通过声明它会抛出method1()会抛出的exception来避免这样做的。它没有捕获这个exception,而是把它传递下去。实际上main()方法也可以这样做,通过声明它会抛出Checked exception来避免使用try/catch程序块(当然我们反对这种做法)。    小结一下:    * Runtime exceptions:    在定义方法时不需要声明会抛出runtime exception;    在调用这个方法时不需要捕获这个runtime exception;    runtime exception是从java.lang.RuntimeException或java.lang.Error类衍生出来的。    * Checked exceptions:    定义方法时必须声明所有可能会抛出的checked exception;    在调用这个方法时,必须捕获它的checked exception,不然就得把它的exception传递下去;    checked exception是从java.lang.Exception类衍生出来的。    二、逻辑上    从逻辑的角度来说,checked exceptions和runtime exception是有不同的使用目的的。checked exception用来指示一种调用方能够直接处理的异常情况。而runtime exception则用来指示一种调用方本身无法处理或恢复的程序错误。    checked exception迫使你捕获它并处理这种异常情况。以java.net.URL类的构建器(constructor)为例,它的每一个构建器都会抛出MalformedURLException。MalformedURLException就是一种checked exception。设想一下,你有一个简单的程序,用来提示用户输入一个URL,然后通过这个URL去下载一个网页。如果用户输入的URL有错误,构建器就会抛出一个exception。既然这个exception是checked exception,你的程序就可以捕获它并正确处理:比如说提示用户重新输入。 

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值