1

00:00:01,050  -->  00:00:07,590
Not let's look at some more cool shortcuts for automatic code Glenning an automatic cogeneration.

2

00:00:08,190  -->  00:00:13,380
Let's begin with automatic quote cleaning first one is organizing imports.

3

00:00:13,650  -->  00:00:14,820
So for that you would use.

4

00:00:14,820  -->  00:00:17,100
Control shift or iron.

5

00:00:17,100  -->  00:00:22,920
What it does is it organizes all the import statements in some predefined order.

6

00:00:22,920  -->  00:00:27,400
It also deletes any import statements that are not used in that class.

7

00:00:27,450  -->  00:00:30,860
So let's just take this class Turing Test which we wrote earlier.

8

00:00:30,890  -->  00:00:34,160
I just added this import statement which is not being used.

9

00:00:34,180  -->  00:00:37,710
And so you see this yellow warning here.

10

00:00:37,710  -->  00:00:41,410
So let's just go ahead and hit Control Shaeffer or.

11

00:00:41,480  -->  00:00:44,790
And as you can see since it's not being used it got deleted.

12

00:00:44,790  -->  00:00:50,690
Now let me show you a different code base where a lot of statements here.

13

00:00:50,880  -->  00:00:58,140
So let me go ahead and copy these javac statements here and it here.

14

00:00:58,560  -->  00:01:01,380
So I'm just creating them.

15

00:01:01,530  -->  00:01:06,380
Let me do a control shift or and they go back to their original place.

16

00:01:06,390  -->  00:01:11,180
You see they go on the run back here too.

17

00:01:11,280  -->  00:01:13,570
So that's Control shift.

18

00:01:13,600  -->  00:01:14,030
Oh.

19

00:01:14,100  -->  00:01:16,310
Or stands for organizing organizing.

20

00:01:16,350  -->  00:01:18,540
So they're organizing the import statements.

21

00:01:18,600  -->  00:01:18,830
OK.

22

00:01:18,840  -->  00:01:20,420
So that's the first one.

23

00:01:20,900  -->  00:01:29,200
To go back to the previous eclipse next is which we have already seen it as can truly shift f underoath

24

00:01:29,210  -->  00:01:30,540
for formatting.

25

00:01:30,540  -->  00:01:32,320
So if you see here and this class.

26

00:01:32,370  -->  00:01:35,040
So this is not indented properly.

27

00:01:35,250  -->  00:01:40,950
And this student object creation statement is also not indented properly.

28

00:01:40,950  -->  00:01:42,510
So it's here and part offered is.

29

00:01:42,530  -->  00:01:43,740
And the next line.

30

00:01:43,740  -->  00:01:49,860
So that's just head control shift F and got indented properly.

31

00:01:49,860  -->  00:01:55,040
Everything is formatted properly and we have seen this in our coding conventions since.

32

00:01:55,110  -->  00:01:55,700
OK.

33

00:01:55,770  -->  00:01:57,490
So that's the second one.

34

00:01:57,510  -->  00:02:04,740
Now if you want to move toward one as if you want to move some chord if you want to shift the entire

35

00:02:04,740  -->  00:02:08,720
code to what's right all you can do is just hit tab.

36

00:02:08,850  -->  00:02:10,430
Now if you want to bring it back.

37

00:02:10,470  -->  00:02:11,850
Hit shift tab.

38

00:02:11,960  -->  00:02:12,330
OK.

39

00:02:12,340  -->  00:02:14,320
And it goes back to the left side.

40

00:02:14,790  -->  00:02:19,180
Let's say if you want to add some comments here let's go here.

41

00:02:19,290  -->  00:02:21,320
Let's see if you want to comment this code.

42

00:02:21,690  -->  00:02:26,100
All you can do is get control and forward slash.

43

00:02:26,100  -->  00:02:31,270
You'll see the got commented out on if you are uncommon then just do the same thing again.

44

00:02:31,350  -->  00:02:32,220
That's it.

45

00:02:32,220  -->  00:02:39,090
Now if you want to insert block chords then hit Control shift and forward slash and there you go you

46

00:02:39,090  -->  00:02:41,510
can see those block notes here.

47

00:02:41,520  -->  00:02:48,540
Now if you're uncommon if you want to uncommented you need to do control shift in backslash for this

48

00:02:49,470  -->  00:02:50,730
and that's it.

49

00:02:50,730  -->  00:02:57,210
So let's just put control forward slash and let's leave it like that.

50

00:02:57,510  -->  00:03:01,770
So that's about some chord cleaning tactics.

51

00:03:01,890  -->  00:03:06,060
Next let's see how we can automatically generate some sort score.

52

00:03:06,120  -->  00:03:10,980
So here I'm going to construct a couple of items and the first one that I'm going to demonstrate as

53

00:03:11,520  -->  00:03:14,990
how we can automatically insert some template.

54

00:03:15,390  -->  00:03:17,290
OK so let's just go out and do that.

55

00:03:17,520  -->  00:03:20,210
But before that let's just recap of this chord.

56

00:03:20,280  -->  00:03:23,530
So this is the code that we wrote in our students demo class.

57

00:03:23,820  -->  00:03:30,600
And here is the Student class which has a few fields like the ID name on gender and so on.

58

00:03:30,680  -->  00:03:38,070
Yeah only three fields are here and here in the student best is tester class where we are creating three

59

00:03:38,070  -->  00:03:44,580
instances just print and then initializing them with name and gender and then just printing the name

60

00:03:44,580  -->  00:03:48,730
here in front of one of those students the name was misspelled.

61

00:03:48,780  -->  00:03:50,130
So we are setting the right name.

62

00:03:50,130  -->  00:03:52,750
And then we are printing the right name once again.

63

00:03:52,800  -->  00:03:55,570
So just a simple student demo.

64

00:03:55,680  -->  00:03:59,280
So let's just go ahead and create a new instance.

65

00:03:59,280  -->  00:04:07,420
So for that new instance of student just type in the keyword new and hit control space on it it will

66

00:04:07,420  -->  00:04:12,920
show a pop up here just select new and the template code is here.

67

00:04:13,140  -->  00:04:17,870
So all we need to do is just fill up these details here so it has to be student.

68

00:04:18,240  -->  00:04:26,980
And this has to be student and we need to pass the arguments for the constructor.

69

00:04:27,000  -->  00:04:35,650
So Karen I'm female that's now go ahead and bring these for students but for that let me just sow so

70

00:04:35,670  -->  00:04:39,480
discord and this needs to be stored and for

71

00:04:42,230  -->  00:04:48,560
so all I'm doing is creating a student array for the elements and the four elements that we have the

72

00:04:48,560  -->  00:04:54,430
four student objects that we how are are being stored in the tree and it's called us a list.

73

00:04:54,440  -->  00:04:57,520
Now let's just print this out.

74

00:04:57,800  -->  00:04:59,330
Let's put in for each.

75

00:04:59,330  -->  00:05:06,870
So this is a key word on his control space once again and said this.

76

00:05:07,520  -->  00:05:10,940
And let's just go ahead and put in the names.

77

00:05:10,940  -->  00:05:24,490
So for this let's just create create two variables also need to do and not get name.

78

00:05:24,500  -->  00:05:31,160
So this is it automatically helps us to pick one of them and their names so that they're counting off

79

00:05:31,380  -->  00:05:38,240
eclipse next string gender.

80

00:05:40,040  -->  00:05:42,650
But there is more than gender method.

81

00:05:42,860  -->  00:05:44,160
So we need to write that.

82

00:05:44,180  -->  00:05:53,210
So it's just this year if we were over here it says this quick fix allows us and gives us an option

83

00:05:53,210  -->  00:05:55,700
to create the method their gender so let's just do that.

84

00:05:55,820  -->  00:06:05,380
So it creates this template code here once again in the Student class so let's just say this in our

85

00:06:05,390  -->  00:06:09,110
gender and this sort of combines.

86

00:06:09,110  -->  00:06:12,630
Now let's put a couple of print statements.

87

00:06:12,950  -->  00:06:24,330
So just type in sys out and then control space and it inserts this Prindle and statement for us.

88

00:06:24,650  -->  00:06:26,450
So just say the

89

00:06:30,440  -->  00:06:37,260
same thing here says how to control space.

90

00:06:38,900  -->  00:06:40,600
So that's the thing.

91

00:06:40,790  -->  00:06:49,370
So you hear we try new and here for each and here says oh come on we can do many other things like you

92

00:06:49,370  -->  00:06:50,780
can try switch.

93

00:06:50,870  -->  00:06:52,910
You can try far.

94

00:06:52,910  -->  00:06:58,450
You can try even the main method you can insert but we already have the main method here.

95

00:06:58,490  -->  00:07:05,840
All you do is Maine and then head control space and let's say if you want to insert like a public method

96

00:07:06,890  -->  00:07:17,800
just type in public underscore method Hensick control space and it creates a template for that.

97

00:07:17,930  -->  00:07:19,680
All you need to do is change.

98

00:07:19,700  -->  00:07:23,470
Or you know insert some return type and the name has to be changed.

99

00:07:23,870  -->  00:07:30,070
So these are some commonly used ones and you might how more so that for me.

100

00:07:30,290  -->  00:07:32,460
Now where are these templates stored.

101

00:07:32,540  -->  00:07:34,310
For that we can go into Windows

102

00:07:36,680  -->  00:07:48,950
preferences just go into java going to editor here and written editor select templates on here you can

103

00:07:48,950  -->  00:07:55,520
see all the names here.

104

00:07:55,670  -->  00:07:57,530
For example for each here.

105

00:07:57,560  -->  00:07:59,520
So these are all the templates that we have.

106

00:07:59,600  -->  00:08:04,020
If you click on for each slide shows you the template.

107

00:08:04,130  -->  00:08:08,600
OK that's where all the templates are.

108

00:08:09,620  -->  00:08:12,950
Let's go ahead and automatically generate more source code.

109

00:08:13,250  -->  00:08:19,160
So let's just create a class called course.

110

00:08:21,020  -->  00:08:22,700
Let's add two variables here

111

00:08:27,380  -->  00:08:29,390
Id a name.

112

00:08:29,750  -->  00:08:32,460
And here we can see this yellow icon.

113

00:08:32,590  -->  00:08:37,060
And if we click at once it's just create getter and sector for ID.

114

00:08:37,070  -->  00:08:43,850
So those getters and setters will be created automatically and we actually looked at this in the information

115

00:08:43,850  -->  00:08:44,820
hiding listen.

116

00:08:44,840  -->  00:08:50,860
So we have already seen this where both getters and setters would be automatically created.

117

00:08:51,080  -->  00:08:52,740
So let's just do it in a different way.

118

00:08:52,760  -->  00:08:59,160
So let's go here into source and select this Jenrette getters and setters.

119

00:08:59,750  -->  00:09:06,080
Here it shows both the fields ID and name so and it says select all and the insertion point.

120

00:09:06,110  -->  00:09:12,470
Let's say after name and let's hit OK here.

121

00:09:12,770  -->  00:09:17,150
As you can see it has created the getters and setters automatically.

122

00:09:17,780  -->  00:09:19,280
So that's one way to do it.

123

00:09:19,400  -->  00:09:28,730
Let's go next let's create a constructor automatically let's go here into source and there is this option

124

00:09:28,730  -->  00:09:31,310
called gendered constructor using friens.

125

00:09:31,310  -->  00:09:35,820
Let's do that let's create a constructor using one or more of these views.

126

00:09:35,840  -->  00:09:43,430
So let's go here let's select on let's just go insertion point after name is fine and it's just hit

127

00:09:43,440  -->  00:09:43,470
.

128

00:09:43,480  -->  00:09:44,330
OK.

129

00:09:44,660  -->  00:09:44,900
OK.

130

00:09:44,900  -->  00:09:52,790
So it created a new constructor and it has two parameters your ID a name and there are initialized here

131

00:09:52,790  -->  00:09:53,740
.

132

00:09:53,960  -->  00:10:00,920
So that's how you would automatically generate ID getters and setters and the constructors also.

133

00:10:00,920  -->  00:10:01,950
So that's about it.

134

00:10:02,070  -->  00:10:08,960
And whatever we have seen and this lesson everything can be done from here from the source.

135

00:10:08,960  -->  00:10:13,990
So as you can see there is organized import here and there is formatting here.

136

00:10:14,450  -->  00:10:20,890
And we have all the getter on several generations and also the constructor generation or here.

137

00:10:20,900  -->  00:10:26,090
So everything can be done here or you can also use the shortcuts like control shift or control shift

138

00:10:26,160  -->  00:10:27,660
F and so on.

139

00:10:28,220  -->  00:10:29,440
That's about it.
