• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 13:25
CET 19:25
KST 03:25
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !8Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
When will we find out if there are more tournament ComeBackTV's documentary on Byun's Career ! Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win RSL Revival - 2025 Season Finals Preview Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump
Tourneys
$5,000+ WardiTV 2025 Championship RSL Offline Finals Info - Dec 13 and 14! Master Swan Open (Global Bronze-Master 2) Winter Warp Gate Amateur Showdown #1: Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
How Rain Became ProGamer in Just 3 Months BGH Auto Balance -> http://bghmmr.eu/ FlaSh on: Biggest Problem With SnOw's Playstyle screp: Command line app to parse SC rep files [BSL21] RO8 Bracket & Prediction Contest
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] WB SEMIFINALS - Saturday 21:00 CET [BSL21] RO8 - Day 2 - Sunday 21:00 CET
Strategy
Game Theory for Starcraft Current Meta Simple Questions, Simple Answers Fighting Spirit mining rates
Other Games
General Games
PC Games Sales Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1825 users

a bit of easy programming help?

Blogs > firefistAce
Post a Reply
firefistAce
Profile Blog Joined September 2010
United States137 Posts
July 11 2011 04:38 GMT
#1
im trying to write an easy program that lets me enter a password and if it's correct it will say access granted.

This is not for homework, it's just something i'm writing for fun to keep my programming knowledge fresh over the summer. im guessing something is not right with the "if" statement here. any help appreciated thanks.

code:

import java.util.Scanner;
public class summer {
public static void main(String [] args){

Scanner input = new Scanner(System.in);
String[] password = new String[1];

System.out.print("You are entering unauthorized territory. Please enter password: ");
password[0] = input.nextLine();

if(password[0] == "1234"){
System.out.print("Access Granted");
}

}


}



Please excuse my English as I am an American on the internet.
TuranoSauR
Profile Joined July 2011
United States22 Posts
July 11 2011 04:46 GMT
#2
Dude I was terrible at C++ when I took it in high school so I heard Java is a little harder good luck trying to figure this out
Terran it up ¯\_(ツ)_/¯
ShadowDrgn
Profile Blog Joined July 2007
United States2497 Posts
July 11 2011 04:48 GMT
#3
Use String.equals, not == when comparing strings.
Of course, you only live one life, and you make all your mistakes, and learn what not to do, and that’s the end of you.
just_nick
Profile Joined August 2009
Canada35 Posts
July 11 2011 04:50 GMT
#4
You are comparing a reference to a string with the string "1234" which will always return false. The proper way of making your comparison in this case would be:

if( password[0].equals("1234") )
SevenBunnies
Profile Blog Joined September 2010
United States24 Posts
July 11 2011 05:28 GMT
#5
As others have said, == is not right. Only with primitives (i.e. int, char, etc.) does == compare values - with objects, it compares the references (physical addresses) of each object. Either use the .equals(), .compareTo(), or .compare() method to check your string's value.
Asday
Profile Joined November 2010
United Kingdom388 Posts
Last Edited: 2011-08-07 07:15:13
August 07 2011 07:13 GMT
#6
I mean no offence by this, but if this is keeping your knowledge "fresh"... Exactly what do they teach in the span of one year nowadays? :o

Edit: WHOA BOY DID I EVER JUST NECRO. Was using the search feature and not paying attention to dates because I'm an idiot. I may have done this to a few threads...
Please log in or register to reply.
Live Events Refresh
Big Brain Bouts
17:00
#102
YoungYakov vs JumyLIVE!
TriGGeR vs Spirit
RotterdaM741
IndyStarCraft 319
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 703
Lowko460
IndyStarCraft 295
SteadfastSC 147
BRAT_OK 53
ProTech42
mouzStarbuck 38
MindelVK 28
DivinesiaTV 17
StarCraft: Brood War
Britney 17606
Rain 1978
Bisu 1869
Shuttle 347
Larva 184
Mini 110
firebathero 108
Dewaltoss 104
BeSt 91
Hyun 87
[ Show more ]
Mind 85
Zeus 65
Killer 62
Aegong 51
ggaemo 45
JYJ 42
Mong 28
910 26
sorry 20
GoRush 15
soO 15
ajuk12(nOOB) 14
Shinee 14
SilentControl 13
JulyZerg 12
Sacsri 12
Dota 2
Gorgc6122
singsing3680
qojqva3196
Counter-Strike
fl0m211
Foxcn109
byalli106
Other Games
FrodaN1070
KnowMe101
C9.Mang083
Trikslyr61
Chillindude31
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota245
League of Legends
• Nemesis4197
• TFBlade220
Other Games
• imaqtpie586
• Shiphtur112
• tFFMrPink 17
Upcoming Events
The PiG Daily
2h 36m
SHIN vs ByuN
Reynor vs Classic
TBD vs herO
Maru vs SHIN
TBD vs Classic
CranKy Ducklings
15h 36m
WardiTV 2025
16h 36m
Reynor vs MaxPax
SHIN vs TBD
Solar vs herO
Classic vs TBD
SC Evo League
18h 6m
Ladder Legends
1d
BSL 21
1d 1h
Sziky vs Dewalt
eOnzErG vs Cross
Sparkling Tuna Cup
1d 15h
Ladder Legends
1d 22h
BSL 21
2 days
StRyKeR vs TBD
Bonyth vs TBD
Replay Cast
2 days
[ Show More ]
Wardi Open
2 days
Monday Night Weeklies
2 days
WardiTV Invitational
4 days
Replay Cast
5 days
WardiTV Invitational
5 days
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 1
WardiTV 2025
META Madness #9
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL Season 19: Qualifier 2
CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.