NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package diziler;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;



public class diziornekleri {



public static void main(String[] args)
{
/* Dizi Tanımlama Şekilleri*/

/*
String[] metin= {"sercan","cetin"};
String metinler[]= {"sercan"};
int [] sayi1=new int[3];
//sayi1[0]=1;
*/
int [] dizi={1,3,5,6,7,8};
System.out.println(dizi[3]);//6'yı yazdırır

int dizi1[];
dizi1=new int[] {1,2,3};

int[] dizi2=new int[3];
dizi2[0]=1;
dizi2[1]=2;
dizi2[2]=3;

String [] dizi3= {"Sercan","Ahmet","Mehmet"};

for (int i = 0; i < dizi3.length; i++)
{
System.out.println(dizi3[i]);
}

System.out.println("----------------------------");

for (String metin : dizi3)
{
System.out.println(metin);
}

//Diziye Eleman Atamak
int [] sifirlarDizisi= {0,0,0,0};
int [] birlerDizisi= {1,1,1,1};
//Dizide Eleman Değiştirme
Arrays.fill(sifirlarDizisi,1);// hepsini bir yaptı
Arrays.fill(birlerDizisi,1,3,0);//1den 3 e kadar 0 yaz 3 dahil değil

System.out.println("----------------------------");

for (int i : birlerDizisi) {
System.out.println(i);
}

//Dizi Karşılaştırma
int [] dizi4= {1,1,1,1};
int [] dizi5= {1,1,1,1};
if(Arrays.equals(dizi4,dizi5)==true)//String vs karşılaştırabilir.
{ System.out.println("diziler eşit");}


System.out.println("----------------------------");

//Dizi Liste Çevirme
//Integer olmalı
Integer[] dizi6 =new Integer[] {1,2,3,4};
List listeYapisi=new ArrayList();

listeYapisi=Arrays.asList(dizi6);

System.out.println("liste elemanları"+listeYapisi);


System.out.println("----------------------------");


//Dizi Kopyalama 3 farklı yöntem

// 1- Yontem
char[] isimSoyisim= {'S','E','R','C','A','N'};
char[] KopyaDizi= {};
KopyaDizi=Arrays.copyOf(isimSoyisim,5);// 5 tane elemanı al
for (int i = 0; i < KopyaDizi.length; i++)
{

System.out.print(KopyaDizi[i]+"t");

}
System.out.println("----------------------------");

// 2- Yontem
char[] isimSoyisim1= {'S','E','R','C','A','N'};
char[] KopyaDizi1= {};
KopyaDizi1=Arrays.copyOfRange(isimSoyisim1,0,4); // 0.indexten 4tane say
for (int i = 0; i < KopyaDizi1.length; i++)
{
System.out.print(KopyaDizi1[i]+"t");

}

System.out.println("----------------------------");

//3- Yontem
int sayilar[]=new int[4];
for (int i = 0; i < sayilar.length; i++) {
sayilar[i]=i+i;
}
int[] sayilar2 = new int[sayilar.length];
for (int i = 0; i < sayilar2.length; i++) {
sayilar2[i]=sayilar[i];
}

System.out.println("----------------------------");

//4. Yontem

int sayilar3[]={1,2,3,4,5,6};
int[] sayilar4 = new int[sayilar3.length];
System.arraycopy(sayilar3,0,sayilar4,0,3);
// kopyası alınacak dizi,
//kaçtan başlıcak,
//hangisi diziye,
//sayılar4 dizisinin kacıncıdan başlıcak
// kactane kopyalıcak
for (int i = 0; i < sayilar4.length; i++)
{
System.out.print(sayilar4[i]);
}
System.out.println();
System.out.println("----------------------------");


//Sıralama
Arrays.sort(sayilar3);
//Arrays.sort(sayilar3,0,5);// kacıncı elemandan kacına sıralıcak
for (int i = 0; i < sayilar3.length; i++)
{
System.out.print(sayilar3[i]);
}
System.out.println();
System.out.println("------------------------");
//Dizide Arama

//Diziyi önce sıralamak gerekir yoksa çalışmaz
int deger=Arrays.binarySearch(sayilar3,2);// hangi dizi 2 sayısını içeriyor
if(deger<0)
System.out.println("Bulunamadı");
System.out.println(deger);//index numarasını verir




}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.