Skip to content

Commit f820db8

Browse files
committed
All Datatypes and Code
1 parent 12837ce commit f820db8

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

Basic.class

-417 Bytes
Binary file not shown.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Below we have the explanation regarding the key elements in the above syntax :-
7979

8080
## Data Types :
8181

82+
### Primitive
83+
8284
- **Boolean** : Used to store the true (1) or false (0).
8385
- **Byte** : This data type is useful in saving the memory space in case for working with large arrays.
8486
- **Short** : This data type comes under the category of integer of 16 bit storage.
@@ -90,6 +92,67 @@ Below we have the explanation regarding the key elements in the above syntax :-
9092

9193
Note : Code is in the Basic.java file above in the Repo.
9294

95+
### Non-Primitive
96+
97+
- **String** : It is a kind of data type which is known from its other standard line, sequence of characters
98+
99+
Syntax Code :
100+
101+
```
102+
String str1 = "This is a simple string in JAVA";
103+
```
104+
105+
- **Class** : It is a kind of user-defined data type in JAVA also in different programming languages which is created in order to create an entity or object in the main class [Source Code]
106+
107+
Syntax Code :
108+
109+
```
110+
class Class_name{
111+
// class members
112+
public int number = 12;
113+
114+
// class methods
115+
public void display(){
116+
System.out.println("Display Function here !");
117+
}
118+
}
119+
```
120+
121+
- **Object** : It is a kind of entity created in order to use the class here !
122+
123+
Syntax Code :
124+
125+
```
126+
class First{
127+
128+
}
129+
130+
class Class_main{
131+
public static void main(String[] a){
132+
First obj1 = new First();
133+
}
134+
}
135+
```
136+
137+
- **Interface** : Interfaces specify what a class must do and not how. It is the blueprint of the class.
138+
139+
Syntax Code :
140+
141+
```
142+
interface interface_name{
143+
// inteface members
144+
// inteface methods but not defined
145+
}
146+
```
147+
148+
- **Arrays** : An Array is a group of like-typed variables that are referred to by a common name.
149+
150+
Syntax Code :
151+
152+
```
153+
datatype array_name = new datatype[length];
154+
```
155+
93156
### Social Media Links :
94157

95158
- [Instagram Page](https://www.instagram.com/coding.needs/)

npdata.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// 3. Class
2+
class new1{
3+
public void display(){
4+
System.out.println("Displaying the Content here !");
5+
}
6+
}
7+
8+
// 5. Interface
9+
interface player{
10+
final int id = 12;
11+
void display();
12+
}
13+
14+
class player1 implements player{
15+
public void display(){
16+
System.out.println("Player have the required details entered !");
17+
}
18+
}
19+
20+
class npdata{
21+
public static void main(String[] a){
22+
23+
// Non-Primitive Data Types
24+
// 1. Strings
25+
String name = "Ack Wolver";
26+
System.out.println("A String data type in JAVA is : " + name);
27+
28+
// 2. Array
29+
int[] ar1;
30+
ar1 = new int[4];
31+
32+
ar1[0] = 23; // initializing the array with some elements
33+
ar1[1] = 34;
34+
ar1[2] = 10;
35+
36+
// 4. Object
37+
new1 first = new new1();
38+
first.display();
39+
40+
// Interface Reference
41+
player1 pl1 = new player1();
42+
player one;
43+
one = pl1;
44+
one.display();
45+
46+
}
47+
}

0 commit comments

Comments
 (0)