کاراکترها و استرینگها در جاوا:
Character and String:
معرفی یک کاراکار آرایه ای به جاوا به صورت زیر می باشد :
Char u;
u="1"
char u[]=new char[10];
char u[]={'a','b','c'};
همان طور که در قسمت بالا مشاهده می کنید یک کاراکتر را می توان مستقیما مانند
Array
* One Dimension array:
Declaration:
Data type array name[]=new data type name[dimension]
Ex:
int test[]=new int [10];
Or
int test[10];// this is usually use in C# and C++ but we can use its in java language too.
- Direct assignment:
int test[]={4,6,8,10};
- Accessing array location:
for (loop initial variable; variable < number or location; variable ++ )
{
Process: - input
- processing data
- output
}
---------------------------------------------------------------------------
Example:
import javax.swing.JOptionPane;
public class onedimesion
{
public static void main(String[]arg)
{
double d[]=new double[10];
String temp;
double result;
for (int i=0; i<10;i++)
{
temp=JOptionPane.showInputDialog("Input d");
d[i]=double.parsedouble(temp);
result=result+d[i];
}
JOptionPane.showMessageDialog(null,"Result is "+ result);
}
}