battle programmers alliance

battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Search
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» auto programming dev
Fri Jan 19, 2018 6:42 pm by Admin

» java eclipse oxygen grimoire
Tue Jan 09, 2018 7:19 pm by Admin

» vb.net megazord string outputter
Tue Jan 09, 2018 7:11 pm by Admin

» win10 shortcut keys
Sun Jan 07, 2018 10:16 pm by Admin

» web site grimoire with html css and JS
Sun Dec 31, 2017 5:37 pm by Admin

» vb.net convert array to xy coodinates
Fri Dec 08, 2017 2:18 pm by Admin

» JS javascript convert number to words
Wed Dec 06, 2017 1:23 pm by Moti Barski

» JS pascal triangle question
Mon Dec 04, 2017 9:54 am by Admin

» youtube emojis
Mon Dec 04, 2017 12:14 am by Admin

January 2018
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031   
CalendarCalendar
Social bookmarking
Social bookmarking digg  Social bookmarking delicious  Social bookmarking reddit  Social bookmarking stumbleupon  Social bookmarking slashdot  Social bookmarking yahoo  Social bookmarking google  Social bookmarking blogmarks  Social bookmarking live      

Bookmark and share the address of battle programmers alliance on your social bookmarking website
Share | 
 

 java eclipse oxygen grimoire

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin
avatar

Posts : 78
Join date : 2011-08-01

PostSubject: java eclipse oxygen grimoire   Tue Jan 09, 2018 7:19 pm

1 install JDK (java developer kit)
install eclipse from eclipse.org choose the java developers install option

check your java version : https://www.youtube.com/watch?v=UokTaTwckDw

also C:\Users\Lenovo\eclipse-workspace
the eclipse folder created by the installer is where your project files get stored

2 when eclipse fires up choose new java project or from file, new, java, java project.


right click the project name in the solution explorer, new, to add packages to contain your classes or to
create a class. when you choose a class make sure to camel case its name and without spaces. also, check
static main void to define it as the main class.

2.2 to change class name :
right click class on the solution explorer, refactor, rename

2.3 comment in out selected code lines : ctrl + /
3 hello world code :

package PL;

public class test2 {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hello world");
}

}

ctrl + f11 to run code
4 making the intelliJ intellisense more sensitive : tool strip, window, preferences , java, editor, content assistent,
auto activation trigger, add abcdefghijklmnopqrstuvwxwz and in upper case and @_ to .

5 var declaration :
int x = 5;

double d1 = 2.5;
int y = (Int)d1; // explicit conversion
byte b1 = 12;
int b2 = b1; // implicit conversion

6 operators
xor operator 5>4 ^ 4==4 //false

7 randomizer :
math.random(); // returns double 0 to 1

8 get user input :
import java.util.Scanner; // at start of code

Scanner s1 = new Scanner(System.in); // after typing this intelliJ should add the import code anyways
int x = s1.nextInt(); // .next(); to input a string

9 shortcut if conditional :
string m1 = (3>1 ? "it is true":"it is false");

10 string jutsus :
compare :
str1.equals(str4);
string old style declare :
str5 = new String("moti rulz");
str.toLowerCase();// you know what it returns

string megazord :
package PL;

import java.util.Scanner;
import static java.lang.System.out;

public class test2 {

public static void main(String[] args) {
// TODO Auto-generated method stub
String s1 = String.format("hi %s %s welcome %d", "king","moti",5);
System.out.println(s1);

}
}
prints :
hi king moti welcome 5

see string format java list for more data types (%s %d)

11 system.nanoTime();

12 loop beef ups:
break; // exits loop while its running
continue; // exit next lines of code in the loop and continue loops execusion

13 arrays :
int[] arr1 = {2,3,4}; // initialize array
System.out.println(Arrays.toString(arr1)); // print array

or

int arr2[]= {1,2,45};
System.out.println(Arrays.toString(arr2)); // full array print for 1D arrays

refer to organ in the array :
// array[x];
int[] arr1 = {2,3,4}; // initialize array
System.out.println(arr1[0]); // prints 2

or

int[] arr1 = {2,3,4}; // initialize array
arr1 = new int[2]; // recreate array you can also : int[] a1 = new int[size integer]
System.out.println(arr1[1]); // prints 0

int[][] g = new int[2][5]; // 2D array
g[1][3] = 5; // access organ
System.out.println(g[0].length); // get inner array size

shallow copy : ar2 = ar1; // changes to either array effect other array

deep copy array :
array2 = Arrays.copyOf(array1,array1.length);

sort array :
Arrays.sort(arr); // sorts arr, no need to return value it is sent by reference (shallow copy)

14 IDE jutsus :

intelliJ : when you type the editor will offer to auto complete code lines, choose code line and enter.

14.2 enable step into and variable watch debug option : click stripe to the left of the code line numbers to
insert a break point, click spider on tool strip next to run code button. right click close to close.

15 methodes :
package t3;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class ttGood {
static String var1 = "hadouken";
public static void main(String[] args) {
// TODO Auto-generated method stub
printMe(); // STATIC FUNCTION CAN ONLY USE static functions
printMe("moti");
hadouken();
hadouken(); // prints : hadouken!!
System.out.println(futsujutsu(3,4)); // prints 7
int[] a2 = {1,2,3,4};
System.out.println(sumArray(a2)); //prints 10
System.out.println(sumArray2(a2));
System.out.println(sumArray2(1,2,3,4,5)); // prints 15
}
public static void printMe() {System.out.println(("rulz"));} // sub returns nothing
public static void printMe(String name) {{System.out.println((name + " rulz"));}}
public static void hadouken() {
var1+="!";
System.out.println((var1));}
public static int futsujutsu(int x,int y) {return x+y;} // shared function
public static int sumArray(int[] a1) {
int sum=0; // for each loop called for int in java :
for (int h:a1) {
sum+=h;

}
return sum;
} // shared function
public static int sumArray2(int...nums) // treat array of variables as an object = var args
{
int sum=0; // for each loop called for int in java :
for (int h:nums) {
sum+=h;

}
return sum;
} // shared function
public static int[] dec(int[] a3) // array returning function
{
int[] newArray = Arrays.copyOf(a3, a3.length);
for (int i = 0; i < newArray.length; i++) {
newArray[i]+=1;
}
return newArray;
}

}

16 string jutsus :
String sX = "hello";
char c1 = sX.charAt(2); // refer to string as array

char[] arr = sX.toCharArray(); // also refer to string as array

17 create and use object classes, examplified with the deck class that uses the card class
when adding those classes do not check the public static void main option which you check for the Main class:



card class :

package gambit;

public class Card {
String type, color;
int level;
public void printCard() {

switch (level) {
case 1:System.out.println("Ace of " + type);break;
case 11:System.out.println("prince of " + type);break;
case 12:System.out.println("queen of " + type);break;
case 13:System.out.println("king of " + type);break;
default:System.out.println(color + " " + type + " level " + level);break;
}
}
}

deck class :

package gambit;

public class Deck {
Card[] cards = new Card[52];
public void initDeck() {
for (int i = 0; i < 13; i++) {
cards[i] = new Card();
cards[i].type = "clubs";
cards[i].color = "black";
cards[i].level = i+1;
}
for (int i = 13; i < 26; i++) {
cards[i] = new Card();
cards[i].type = "hearts";
cards[i].color = "red";
cards[i].level = i-12;
}
for (int i = 26; i < 39; i++) {
cards[i] = new Card();
cards[i].type = "spades";
cards[i].color = "black";
cards[i].level = i-25;
}
for (int i = 39; i < 52; i++) {
cards[i] = new Card();
cards[i].type = "diamonds";
cards[i].color = "red";
cards[i].level = i-38;
}
}
public void printDeck() {
for (int i = 0; i < 52; i++) {
cards[i].printCard();
}

}
}

Main class :

package gambit;

public class Main {

public static void main(String[] args) {
// TODO Auto-generated method stub
Deck d1 = new Deck();
d1.initDeck();
d1.printDeck();
}

}

18 reseting the solution explorer window :
from the tool strip : window,show view, package explorer

_________________
kurayami no kagi  _____    
Back to top Go down
View user profile https://yotamarker.justforum.net
 
java eclipse oxygen grimoire
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» [Help] How to use Selenium RC with Java Eclipse IDE
» Verify command when used with Java,JUNIT and Eclipse
» Getting the error msg 'Error: Could not find or load main class java-jar' while executing the selenium code in eclipse
» Getting error when i run selenium script in Eclipse, please help
» Eclipse setup with selenium RC

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: