Aplicatie Java Cu Siruri Dinamice Stringbuffer

  • Uploaded by: deianira
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Aplicatie Java Cu Siruri Dinamice Stringbuffer as PDF for free.

More details

  • Words: 152
  • Pages: 1
// Aplicatie Java pentru lucrul cu siruri dinamice ;clasa StringBuffer //lucrul cu clasa StringBuffer;aceasta clasa se ocupa cu procesarea sirurilor dinamice //cerintele aplicatiei: -capacitatea unui obiect StringBuffer; // -lungimea unui ----||-----//-modificarea capacitatii unui ------||----//-schimbarea lungimii unui obiect StringBuffer; //-adaugarea unui sir la sfarsitul unui obiect StringBuffer; //-schimbarea unui caracter din sir; //-conversia unui obiect StringBuffer catre String; import java.lang.*; public class Siruri_String_Buffer { public static void main (String[] args) { //declararea si crearea unui obiect StringBuffer StringBuffer sir1=new StringBuffer("qwertyuiopasdfghjklzxcvbnm"); int lungime=sir1.length(); int capacitate=sir1.capacity(); StringBuffer sir2=new StringBuffer("liubliana"); //afisam lungimea si capacitatea sirurilor sir1 si sir2 System.out.println("Lungimea sirului 1 este:"+sir1.length()+" si lungimea sirului 2 este:"+sir2.length()); System.out.println("Capacitatea sirului 1 este:"+sir1.capacity()+" si capacitatea sirului 2 este:"+sir2.capacity()); //-modificarea capacitatii unui ------||----//-schimbarea lungimii unui obiect StringBuffer; sir1.ensureCapacity(42); sir1.setLength(30); System.out.println("noua capacitatea a sirului1 este:"+sir1.capacity()+" este:"+sir1.length()); //-schimbarea unui caracter din sir; sir2.setCharAt(1,'j'); sir2.setCharAt(5,'j'); System.out.println("noul sir sir2:"+sir2); //-conversia unui obiect StringBuffer catre String; String sir3=sir2.toString(); System.out.println("sir3:"+sir3); } }

si noua lungime

Related Documents


More Documents from "lil_petrea"

May 2020 18
Prefixoide
December 2019 12
Kirac-siyah Gece Lyrics
December 2019 17